From: Bernd Schmidt Date: Wed, 29 Apr 2009 15:09:37 +0000 (+0000) Subject: bfin.c (bfin_optimize_loop): If we need a scratch reg, scan backwards to try to find... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e50e30817e79d18bb9e662d70940cc79dbbe9e15;p=gcc.git bfin.c (bfin_optimize_loop): If we need a scratch reg, scan backwards to try to find a constant to initialize it. * config/bfin/bfin.c (bfin_optimize_loop): If we need a scratch reg, scan backwards to try to find a constant to initialize it. From-SVN: r146974 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c18dfc2f59..8f8e05d6f90 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-04-29 Bernd Schmidt + + * config/bfin/bfin.c (bfin_optimize_loop): If we need a scratch reg, + scan backwards to try to find a constant to initialize it. + 2009-04-29 Richard Guenther PR middle-end/39937 diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 14f7f519317..0808522afdf 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -3784,7 +3784,7 @@ bfin_optimize_loop (loop_info loop) rtx insn, last_insn; rtx loop_init, start_label, end_label; rtx reg_lc0, reg_lc1, reg_lt0, reg_lt1, reg_lb0, reg_lb1; - rtx iter_reg, scratchreg; + rtx iter_reg, scratchreg, scratch_init, scratch_init_insn; rtx lc_reg, lt_reg, lb_reg; rtx seq, seq_end; int length; @@ -3838,18 +3838,40 @@ bfin_optimize_loop (loop_info loop) goto bad_loop; } scratchreg = NULL_RTX; + scratch_init = iter_reg; + scratch_init_insn = NULL_RTX; if (!PREG_P (iter_reg) && loop->incoming_src) { + basic_block bb_in = loop->incoming_src; int i; for (i = REG_P0; i <= REG_P5; i++) if ((df_regs_ever_live_p (i) || (funkind (TREE_TYPE (current_function_decl)) == SUBROUTINE && call_used_regs[i])) - && !REGNO_REG_SET_P (df_get_live_out (loop->incoming_src), i)) + && !REGNO_REG_SET_P (df_get_live_out (bb_in), i)) { scratchreg = gen_rtx_REG (SImode, i); break; } + for (insn = BB_END (bb_in); insn != BB_HEAD (bb_in); + insn = PREV_INSN (insn)) + { + rtx set; + if (NOTE_P (insn) || BARRIER_P (insn)) + continue; + set = single_set (insn); + if (set && rtx_equal_p (SET_DEST (set), iter_reg)) + { + if (CONSTANT_P (SET_SRC (set))) + { + scratch_init = SET_SRC (set); + scratch_init_insn = insn; + } + break; + } + else if (reg_mentioned_p (iter_reg, PATTERN (insn))) + break; + } } if (loop->incoming_src) @@ -4092,11 +4114,13 @@ bfin_optimize_loop (loop_info loop) } else if (scratchreg != NULL_RTX) { - emit_insn (gen_movsi (scratchreg, iter_reg)); + emit_insn (gen_movsi (scratchreg, scratch_init)); loop_init = gen_lsetup_with_autoinit (lt_reg, start_label, lb_reg, end_label, lc_reg, scratchreg); seq_end = emit_insn (loop_init); + if (scratch_init_insn != NULL_RTX) + delete_insn (scratch_init_insn); } else { @@ -4106,12 +4130,14 @@ bfin_optimize_loop (loop_info loop) rtx pop = gen_frame_mem (SImode, gen_rtx_POST_INC (SImode, stack_pointer_rtx)); emit_insn (gen_movsi (push, p0reg)); - emit_insn (gen_movsi (p0reg, iter_reg)); + emit_insn (gen_movsi (p0reg, scratch_init)); loop_init = gen_lsetup_with_autoinit (lt_reg, start_label, lb_reg, end_label, lc_reg, p0reg); emit_insn (loop_init); seq_end = emit_insn (gen_movsi (p0reg, pop)); + if (scratch_init_insn != NULL_RTX) + delete_insn (scratch_init_insn); } if (dump_file)