Message ID | 4C18F46C.6090809@codesourcery.com |
---|---|
State | New |
Headers | show |
On 06/16/10 09:57, Maxim Kuvyrkov wrote: > IRA and reload has special relationship with pseudos that are set only > once. When such pseudos initialized with constants or instances that > can be considered constant across the function, reload can > rematerialize them instead of spilling or apply other optimizations. > > This patch makes sure that we don't unnecessarily set same pseudo more > than once. > > OK to apply? OK. THanks, Jeff
On 6/21/10 9:55 PM, Jeff Law wrote: > On 06/16/10 09:57, Maxim Kuvyrkov wrote: >> IRA and reload has special relationship with pseudos that are set only >> once. When such pseudos initialized with constants or instances that >> can be considered constant across the function, reload can >> rematerialize them instead of spilling or apply other optimizations. >> >> This patch makes sure that we don't unnecessarily set same pseudo more >> than once. >> >> OK to apply? > OK. THanks, Thank you for reviewing this and other patches. There is similar code in gcse.c:pre_delete(): /* Create a pseudo-reg to store the result of reaching expressions into. Get the mode for the new pseudo from the mode of the original destination pseudo. */ if (expr->reaching_reg == NULL) expr->reaching_reg = gen_reg_rtx_and_attrs (SET_DEST (set)); gcse_emit_move_after (expr->reaching_reg, SET_DEST (set), insn); delete_insn (insn); occr->deleted_p = 1; changed = 1; gcse_subst_count++; From quick look at PRE, it seem that creating a new pseudo for PRE is also correct. Do you know off-hand if this indeed is the case? Thanks,
On 06/22/10 06:08, Maxim Kuvyrkov wrote: > On 6/21/10 9:55 PM, Jeff Law wrote: >> On 06/16/10 09:57, Maxim Kuvyrkov wrote: >>> IRA and reload has special relationship with pseudos that are set only >>> once. When such pseudos initialized with constants or instances that >>> can be considered constant across the function, reload can >>> rematerialize them instead of spilling or apply other optimizations. >>> >>> This patch makes sure that we don't unnecessarily set same pseudo more >>> than once. >>> >>> OK to apply? >> OK. THanks, > > Thank you for reviewing this and other patches. > > There is similar code in gcse.c:pre_delete(): > > /* Create a pseudo-reg to store the result of reaching > expressions into. Get the mode for the new pseudo from > the mode of the original destination pseudo. */ > if (expr->reaching_reg == NULL) > expr->reaching_reg = gen_reg_rtx_and_attrs (SET_DEST (set)); > > gcse_emit_move_after (expr->reaching_reg, SET_DEST (set), insn); > delete_insn (insn); > occr->deleted_p = 1; > changed = 1; > gcse_subst_count++; > > From quick look at PRE, it seem that creating a new pseudo for PRE is > also correct. Do you know off-hand if this indeed is the case? Creating a new pseudo for PRE would be good; however, it's not immediately clear to me if creating a new pseudo is safe given the way deletion & insertion work for our implementation of PRE. jeff
diff --git a/gcc/gcse.c b/gcc/gcse.c index 74986a4..45cab70 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -4437,8 +4437,13 @@ hoist_code (void) /* Create a pseudo-reg to store the result of reaching expressions into. Get the mode for the new pseudo - from the mode of the original destination pseudo. */ - if (expr->reaching_reg == NULL) + from the mode of the original destination pseudo. + + It is important to use new pseudos whenever we + emit a set for it in insert_insn_end_basic below. + This will allow reload to use equivalence for + registers that are set only once. */ + if (!insn_inserted_p) expr->reaching_reg = gen_reg_rtx_and_attrs (SET_DEST (set));