------- Comment #2 from kkojima at gcc dot gnu dot org 2010-07-30 00:50 ------- With -g, .ira for the above test case has the insns:
(insn 143 141 229 14 (set (reg/f:SI 1 r1 [238]) (const_int 2046 [0x7fe])) yyy.c:25 176 {movsi_ie} (expr_list:REG_EQUAL (const_int 2046 [0x7fe]) (nil))) (debug_insn 229 143 144 14 (var_location:SI D#2 (reg/v/f:SI 8 r8 [orig:210 buf ] [210])) -1 (nil)) (insn 144 229 145 14 (set (reg/f:SI 1 r1 [238]) (plus:SI (reg/f:SI 1 r1 [238]) (reg/v/f:SI 8 r8 [orig:210 buf ] [210]))) yyy.c:25 35 {*addsi3_compact} (expr_list:REG_EQUAL (plus:SI (reg/v/f:SI 8 r8 [orig:210 buf ] [210]) (const_int 2046 [0x7fe])) (nil))) (insn 145 144 146 14 (set (reg:QI 2 r2 [240]) (const_int 0 [0])) yyy.c:25 186 {movqi_i} (expr_list:REG_EQUIV (const_int 0 [0]) (nil))) (insn 146 145 38 14 (set (mem:QI (reg/f:SI 1 r1 [238]) [0 MEM[(char *)buf_1(D) + 2046B]+0 S1 A8]) (reg:QI 2 r2 [240])) yyy.c:25 186 {movqi_i} (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) When debug_insn 229 is absent, reload_combine_recognize_pattern converts them to the insns like (insn 143 141 145 14 (set (reg:SI 0 r0) (const_int 2046 [0x7fe])) xxx.c:25 176 {movsi_ie} (expr_list:REG_EQUAL (const_int 2046 [0x7fe]) (nil))) (insn 145 143 146 14 (set (reg:QI 2 r2 [240]) (const_int 0 [0])) xxx.c:25 186 {movqi_i} (expr_list:REG_EQUIV (const_int 0 [0]) (nil))) (insn 146 145 38 14 (set (mem:QI (plus:SI (reg:SI 0 r0) (reg/v/f:SI 8 r8 [orig:210 buf ] [210])) [0 MEM[(char *)buf_1(D) + 2046B]+0 S1 A8]) (reg:QI 2 r2 [240])) xxx.c:25 186 {movqi_i} (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) but this isn't done with debug_insn 229. It seems that reload_combine_recognize_pattern only looks prev_nonnote_insn of insn 145 as the candidate of (set (REGX) (CONST_INT)) insn and the debug_insn confuses it. I've confirmed that the patch --- ORIG/trunk/gcc/postreload.c 2010-07-28 09:38:05.000000000 +0900 +++ trunk/gcc/postreload.c 2010-07-30 08:42:50.000000000 +0900 @@ -1113,12 +1113,20 @@ reload_combine_recognize_pattern (rtx in && last_label_ruid < reg_state[regno].use_ruid) { rtx base = XEXP (src, 1); - rtx prev = prev_nonnote_insn (insn); - rtx prev_set = prev ? single_set (prev) : NULL_RTX; + rtx prev; + rtx prev_set; rtx index_reg = NULL_RTX; rtx reg_sum = NULL_RTX; int i; + /* Find the previous non-note/dubug insn. */ + prev = insn; + do { + prev = prev_nonnote_insn (prev); + } while (prev && DEBUG_INSN_P (prev)); + + prev_set = prev ? single_set (prev) : NULL_RTX; + /* Now we need to set INDEX_REG to an index register (denoted as REGZ in the illustration above) and REG_SUM to the expression register+register that we want to use to substitute uses of REG fixes the problem. Perhaps {next,prev}_nonnote_nondebug_insn should be added to emit-rtl.c and use it here. Thoughts? -- kkojima at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|-g changes the generated |[4.6 Regression] -g changes |code for gcc/sched-vis.c on |the generated code for |SH |gcc/sched-vis.c on SH http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45137