------- Comment #4 from steven at gcc dot gnu dot org 2010-03-19 18:39 ------- Comment #3 makes no sense: There is no such thing as target specific GIMPLE canonicalization. And also there is no hoisting for GIMPLE so the form of the IR given in comment #3 wouldn't make a difference.
Even without -frename-registers, the extra insn is there. GCC trunk revision 157579 generates the following code with "-Os -mthumb -march=armv5te": foo: push {lr} cmp r0, #9 beq .L2 mov r3, #0 str r3, [r1] b .L3 .L2: mov r3, #0 str r3, [r1, #4] .L3: mov r0, #3 @ sp needed for prologue pop {pc} Here the "mov r3, #0" after ".L2:" and after "beq .L2" could be unified e.g. with hoisting or with head-merging (inverse of tail merging). Just before the RTL hoisting pass, the code looks like this (.152r.cprop1 dump): 5 NOTE_INSN_BASIC_BLOCK 2 r135:SI=r0:SI REG_DEAD: r0:SI 3 r136:SI=r1:SI REG_DEAD: r1:SI 4 NOTE_INSN_FUNCTION_BEG 7 pc={(r135:SI==0x9)?L13:pc} REG_DEAD: r135:SI REG_BR_PROB: 0xec6 8 NOTE_INSN_BASIC_BLOCK 9 r137:SI=0x0 10 [r136:SI]=r137:SI REG_EQUAL: 0x0 REG_DEAD: r137:SI REG_DEAD: r136:SI L13: 14 NOTE_INSN_BASIC_BLOCK 15 r138:SI=0x0 16 [r136:SI+0x4]=r138:SI REG_EQUAL: 0x0 REG_DEAD: r138:SI REG_DEAD: r136:SI L17: 18 NOTE_INSN_BASIC_BLOCK 23 r0:SI=0x3 26 use r0:SI Note the insns "9 r137:SI=0x0" and "15 r138:SI=0x0". This could be hoisted in the RTL HOIST pass. But this doesn't happen because the hoisting pass doesn't record constants as hoisting candidates. The "expression passes" in gcse.c (PRE and HOIST) ignore all instructions of the form "(set (reg) (const))" because want_to_gcse_p() returns false for them. This is a deliberate decision in the implementation. Thus, there is nothing target specific about this problem. The analysis of comment #3 makes no sense, but this is also not really a dup of bug 23286. -- steven at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- OtherBugsDependingO| |33828 nThis| | Severity|normal |enhancement Status|UNCONFIRMED |NEW Component|target |rtl-optimization Ever Confirmed|0 |1 GCC build triplet|i686-linux | GCC host triplet|i686-linux | Last reconfirmed|0000-00-00 00:00:00 |2010-03-19 18:39:40 date| | Summary|GCSE opportunity in if |Constants are never |statement |candidates for hoisting http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40956