optimization/5844: Bad code generated for -O2 -mcpu=i586

H . J . Lu hjl@lucon.org
Tue Mar 5 18:26:00 GMT 2002


The bug is in copyprop_hardreg_forward. It turns

(insn 83 35 84 (set (reg:SI 0 eax)
        (mem/s:SI (plus:SI (reg/v/f:SI 2 ecx [58])
                (const_int 4 [0x4])) [4 <variable>.uncaughtExceptions+0 S4 A32])) -1 (nil)
    (nil))

(insn 84 83 85 (parallel[
            (set (reg:SI 0 eax)
                (plus:SI (reg:SI 0 eax)
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(insn 85 84 40 (set (mem/s:SI (plus:SI (reg/v/f:SI 2 ecx [58])
                (const_int 4 [0x4])) [4 <variable>.uncaughtExceptions+0 S4
A32])
        (reg:SI 0 eax)) -1 (nil)
    (expr_list:REG_DEAD (reg:SI 0 eax)
        (nil)))

into

(insn 83 35 84 (set (reg:SI 0 eax) 
        (mem/s:SI (plus:SI (reg:SI 0 eax [58])
                (const_int 4 [0x4])) [4 <variable>.uncaughtExceptions+0 S4
A32])
) 45 {*movsi_1} (nil)
    (nil))

(insn 84 83 85 (parallel[  
            (set (reg:SI 0 eax)
                (plus:SI (reg:SI 0 eax)
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ] ) 207 {*addsi_1} (nil)
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(insn 85 84 40 (set (mem/s:SI (plus:SI (reg:SI 0 eax [58])
                (const_int 4 [0x4])) [4 <variable>.uncaughtExceptions+0 S4
A32])
        (reg:SI 0 eax)) 45 {*movsi_1} (nil)
    (expr_list:REG_DEAD (reg:SI 0 eax [58])
        (nil)))


When it sees

(insn 83 35 84 (set (reg:SI 0 eax)
        (mem/s:SI (plus:SI (reg/v/f:SI 2 ecx [58])
                (const_int 4 [0x4])) [4 <variable>.uncaughtExceptions+0 S4 A32])) -1 (nil)
    (nil))

It believes it can replace ecx with eax since it uses the value data
from its predecessor where eax == ecx. Shouldn't it update the value
data before passing it to copyprop_hardreg_forward_1?



H.J.



More information about the Gcc-bugs mailing list