------- Comment #14 from steven at gcc dot gnu dot org 2010-02-04 15:19 ------- Part of the problem comes from the way IVOPTS optimizes the memory access:
;; Generating RTL for gimple basic block 3 ;; D.1814_10 = MEM[base: D.1846_29]; (insn 52 51 0 tst.c:6 (set (reg:SI 172 [ D.1814 ]) (mem:SI (reg:SI 179 [ ivtmp.20 ]) [2 *D.1846_29 S4 A32])) -1 (nil)) ;; ivtmp.20_24 = ivtmp.20_25 + 4; (insn 53 52 0 tst.c:6 (set (reg:SI 179 [ ivtmp.20 ]) (plus:SI (reg:SI 179 [ ivtmp.20 ]) (const_int 4 [0x4]))) -1 (nil)) ;; MEM[base: D.1847_30, offset: 4294967292] = D.1816_13; (insn 54 53 55 tst.c:6 (set (reg:SI 189) (mult:SI (reg:SI 172 [ D.1814 ]) (reg:SI 180 [ pretmp.11 ]))) -1 (nil)) (insn 55 54 0 tst.c:6 (set (mem:SI (plus:SI (reg:SI 179 [ ivtmp.20 ]) (const_int -4 [0xfffffffffffffffc])) [2 *D.1847_30 S4 A32]) (reg:SI 189)) -1 (nil)) ;; if (ivtmp.20_24 != D.1849_32) (insn 57 55 58 tst.c:4 (set (reg:CC 24 cc) (compare:CC (reg:SI 179 [ ivtmp.20 ]) (reg:SI 183 [ D.1849 ]))) -1 (nil)) (jump_insn 58 57 0 tst.c:4 (set (pc) (if_then_else (ne (reg:CC 24 cc) (const_int 0 [0x0])) (label_ref 56) (pc))) -1 (expr_list:REG_BR_PROB (const_int 9844 [0x2674]) (nil))) This yields the sequence: 52 r172:SI=[r179:SI] 53 r179:SI=r179:SI+0x4 54 r189:SI=r172:SI*r180:SI 55 [r179:SI-0x4]=r189:SI and we never get rid of this again. There is another bug related to this one: bug 31849. The patch there probably needs dusting off, and then I'll see if it improves things for this bug as well. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36712