Hi,

I'm debugging a problem with the GCC 4.1 old loop optimizer.

Consider the following example:

After gcse1 a loop body contains the following two insns. Note that gcse
has already replaced r974 with r1218 in insn 1743 and has attached a REG_EQUAL
note. Insn 2308 stays as a dead store - maybe thats what confuses the loop
optimizer.

(insn 2308 1740 1743 111 (set (reg/f:DI 974)
        (const:DI (unspec:DI [
                    (symbol_ref:DI ("local") <var_decl 0x200004c9dc0 local>)
                ] 110))) 49 {*movdi_larl} (nil)
    (expr_list:REG_EQUAL (const:DI (unspec:DI [
                    (symbol_ref:DI ("local") <var_decl 0x200004c9dc0 local>)
                ] 110))
        (nil)))

(insn 1743 2308 1744 111 (set (reg/f:DI 973)
        (mem/u/c:DI (reg/f:DI 1218) [0 S8 A8])) 51 {*movdi_64} (nil)
    (expr_list:REG_EQUAL (mem/u/c:DI (reg/f:DI 974) [0 S8 A8])
        (nil)))


The old-loop output shows that only insn 1743 was moved to the
loop preheader:

Insn 2308: regno 974 (life 0), move-insn savings 1 not desirable
Insn 1743: regno 973 (life 19), savings 1  moved to 2395

Unfortunately the REG_EQUAL note of insn 1743 is NOT deleted since 
the value of r974 is loop invariant.


The loop optmizer decided to load the src of insn 1743 into a new pseudo
(the insert_temp flag is set) resulting in:

(insn 2395 2394 2397 108 (set (reg:DI 1229)
        (mem/u/c:DI (reg/f:DI 1218) [0 S8 A8])) -1 (nil)
    (expr_list:REG_EQUAL (mem/u/c:DI (reg/f:DI 974) [0 S8 A8])
        (nil)))

before loop start and insn 2308 still in the loop body:

(insn 2308 1740 2396 110 (set (reg/f:DI 974)
        (const:DI (unspec:DI [
                    (symbol_ref:DI ("local") <var_decl 0x200004c9dc0 local>)
                ] 110))) -1 (nil)
    (expr_list:REG_EQUAL (const:DI (unspec:DI [
                    (symbol_ref:DI ("local") <var_decl 0x200004c9dc0 local>)
                ] 110))
        (nil)))


The REG_EQUAL note is then used by cse to create an uninitialized memory access.


I don't see a fix other than removing *ALL* REG_EQUAL notes when hoisting
insns from the loop body.  Would that be ok or too pessimistic?

Bye,

-Andreas-

Reply via email to