This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Reload reloading outdated values ?


I'm working my way through a code generation bug in my GCC backend,
and I tracked it down to the reload pass. This is on a 4.7 codebase.

The generated insn stream contains these instructions (from the IRA dump)

(insn 130 113 137 4 (set (reg:SI 229 [ D.10726 ])
        (mem/u:SI (plus:SI (and:SI (mult:SI (subreg:SI (reg:DI 6835) 0)
                        (const_int 4 [0x4]))
                    (const_int 1020 [0x3fc]))
                (reg/f:SI 6823)) [2 Table3 S4 A32])) testcase.h:235
122 {*real_movsi}
     (expr_list:REG_EQUIV (mem/u:SI (plus:SI (and:SI (mult:SI
(subreg:SI (reg:DI 6835) 0)
                        (const_int 4 [0x4]))
                    (const_int 1020 [0x3fc]))
                (reg/f:SI 6823)) [2 Table3 S4 A32])

 and a bit further:

(insn 170 5420 109 4 (set (reg:SI 3357)
        (xor:SI (reg:SI 219 [ D.10716 ])
            (reg:SI 229 [ D.10726 ]))) testcase.h:235 32 {*xor}
     (expr_list:REG_DEAD (reg:SI 229 [ D.10726 ])
        (expr_list:REG_DEAD (reg:SI 219 [ D.10716 ])

After reload I get this insn sequence generated:

(insn 6061 5420 170 4 (set (reg:SI 44 r44)
        (mem/u/c:SI (plus:SI (and:SI (mult:SI (reg:SI 8 r8 [6835])
                        (const_int 4 [0x4]))
                    (const_int 1020 [0x3fc]))
                (reg/f:SI 21 r21 [6823])) [2 Table3 S4 A32]))
testcase.h:235 122 {*real_movsi}

(insn 170 6061 109 4 (set (reg:SI 54 r54 [3357])
        (xor:SI (reg:SI 54 r54 [orig:219 D.10716 ] [219])
            (reg:SI 44 r44))) testcase.h:235 32 {*xor}

The original insn 130 has disappeared, and the insn 6061 has been
generated by reload using the REG_EQUIV note from the original
instruction. The issue is that the r8 register used in the insn 6061
doesn't have the value it would have had at the location of the
original insn 130, thus the generated instruction doesn't load the
right value from memory. The only check I see on memory references in
reload is strict_legitimate_address_p which is true when tested (ie,
with pseudos 6835 and 6823 allocated), but nothing checks that the
expression is still valid when using it as reload for pseudo 229.

Something must be wrong, as I don't see how reload can safely move
memory expressions other than constant addresses around like this. I'm
not sure it's really a reload issue, as I don't know enough of its
inner workings. For example it might be that the REG_EQUIV note
shouldn't be there in the first place. Could someone tell me what I
should be looking at to understand the issue?

Many thanks,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]