http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56442
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-02-25
CC| |gjl at gcc dot gnu.org
Component|target |other
Ever Confirmed|0 |1
Severity|major |normal
--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2013-02-25
10:56:02 UTC ---
Enabling others to understand this...
In .reload dump, we have correct code:
(insn 418 417 113 3 (set (reg:HI 24 r24)
(const:HI (plus:HI (symbol_ref:HI ("array") [flags 0x2] <var_decl
0x1e405a0 array>)
(const_int 4 [0x4])))) 32 {*movhi}
(nil))
(insn 113 418 114 3 (set (reg:HI 14 r14 [94])
(minus:HI (reg:HI 14 r14 [94])
(reg:HI 24 r24))) 65 {subhi3}
(nil))
(insn 114 113 115 3 (set (reg:HI 14 r14 [94])
(lshiftrt:HI (reg:HI 14 r14 [94])
(const_int 2 [0x2]))) 217 {lshrhi3}
(nil))
(insn 115 114 118 3 (parallel [
(set (reg:HI 14 r14 [94])
(and:HI (reg:HI 14 r14 [94])
(const_int 3 [0x3])))
(clobber (reg:QI 25 r25))
]) 175 {andhi3}
(nil))
(insn 118 115 119 3 (set (reg:SF 18 r18 [orig:65 D.1335 ] [65])
(mem:SF (symbol_ref:HI ("array") [flags 0x2] <var_decl 0x1e405a0
array>) [2 MEM[base: D.1358_18, offset: 0B]+0 S4 A8])) foo.c:15 37 {*movsf}
(nil))
(insn 119 118 122 3 (set (reg:HI 28 r28 [orig:96 ivtmp.10 ] [96])
(const:HI (plus:HI (symbol_ref:HI ("array") [flags 0x2] <var_decl
0x1e405a0 array>)
(const_int 4 [0x4])))) 32 {*movhi}
(expr_list:REG_EQUAL (const:HI (plus:HI (symbol_ref:HI ("array") [flags
0x2] <var_decl 0x1e405a0 array>)
(const_int 4 [0x4])))
(nil)))
This is changed by .postreload to:
(insn 119 118 122 3 (set (reg:HI 28 r28 [orig:96 ivtmp.10 ] [96])
(reg:HI 24 r24)) 32 {*movhi}
(expr_list:REG_EQUAL (const:HI (plus:HI (symbol_ref:HI ("array") [flags
0x2] <var_decl 0x1e405a0 array>)
(const_int 4 [0x4])))
(nil)))
This is wrong because reg:HI 24 is (partly) clobbered by insn 115 and thus
reg:HI 24 must not be used past insn 115.
Component is not target, the target description of andhi3 insn is all right.
According to S, the bad transformation happens in:
postreload.c:reload_cse_move2add()