https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119594

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
First of all, REG_UNUSED/REG_DEAD notes are only officially meaningful in
passes which df_add_note_problem before df_analyze, which is cse1 and regcprop
but not fwprop.
But I actually don't see anything incorrect on the REG_UNUSED note even if that
wasn't the case, we have
(insn 7 2 8 2 (set (reg/v:DI 101 [ g ])
        (const_int -1 [0xffffffffffffffff])) "pr119594.c":8:10 95
{*movdi_internal}
     (nil))
at the start of the function, then one loop and afterwards no more looping. 
And in there
(insn 26 24 27 7 (set (reg:DI 104 [ g ])
        (zero_extend:DI (subreg:SI (reg/v:DI 101 [ g ]) 0))) "pr119594.c":11:8
175 {*zero_extendsidi2}
     (expr_list:REG_DEAD (reg/v:DI 101 [ g ])
        (nil)))
(insn 27 26 28 7 (set (reg/v:DI 101 [ g ])
        (reg:DI 104 [ g ])) "pr119594.c":11:8 95 {*movdi_internal}
     (expr_list:REG_DEAD (reg:DI 104 [ g ])
        (expr_list:REG_UNUSED (reg/v:DI 101 [ g ])
            (nil))))
(insn 28 27 29 7 (set (reg:DI 105)
        (const_int 4294967295 [0xffffffff])) "pr119594.c":12:3 95
{*movdi_internal}
     (nil))
(insn 29 28 30 7 (set (reg:DI 5 di)
        (reg:DI 105)) "pr119594.c":12:3 95 {*movdi_internal}
     (expr_list:REG_EQUAL (const_int 4294967295 [0xffffffff])
        (expr_list:REG_DEAD (reg:DI 105)
            (nil))))
That IMHO correctly reflects the state, there is MEM <unsigned long> [(int
*)&g] = 18446744073709551615; first and then later g[1] = 0; which affectively
changes it to 
MEM <unsigned long> [(int *)&g] = 0xffffffff;
And g is otherwise unused.
Now, fwprop1 turns that info
(insn 27 24 28 7 (set (reg/v:DI 101 [ g ])
        (zero_extend:DI (subreg:SI (reg/v:DI 101 [ g ]) 0))) "pr119594.c":11:8
175 {*zero_extendsidi2}
     (expr_list:REG_EQUAL (const_int 4294967295 [0xffffffff])
        (expr_list:REG_UNUSED (reg/v:DI 101 [ g ])
            (nil))))
(insn 28 27 29 7 (set (reg:DI 105)
        (const_int 4294967295 [0xffffffff])) "pr119594.c":12:3 95
{*movdi_internal}
     (nil))
(insn 29 28 30 7 (set (reg:DI 5 di)
        (reg:DI 105)) "pr119594.c":12:3 95 {*movdi_internal}
     (expr_list:REG_EQUAL (const_int 4294967295 [0xffffffff])
        (expr_list:REG_DEAD (reg:DI 105)
            (nil))))
(that part is reasonable) but at the same time it removed insn 7, which is not
correct because its SET_DEST is used in insn 27.

Reply via email to