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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems in *.reload we have:
(insn 5 4 6 2 (set (reg/v/f:SI 4 si [orig:504 Im ] [504])
        (mem/f/c:SI (plus:SI (reg/f:SI 7 sp)
                (const_int 540 [0x21c])) [3 Im+0 S4 A32])) "hc2cf2_16.c":456:1
85 {*movsi_internal}
     (expr_list:REG_EQUIV (mem/f/c:SI (plus:SI (reg/f:SI 16 argp)
                (const_int 12 [0xc])) [3 Im+0 S4 A32])
        (nil)))
...
(insn 487 486 488 3 (set (mem/f/c:SI (plus:SI (reg/f:SI 7 sp)
                (const_int 540 [0x21c])) [3 Im+0 S4 A32])
        (reg/v/f:SI 4 si [orig:504 Im ] [504])) "hc2cf2_16.c":691:14 85
{*movsi_internal}
     (nil))
(insn 488 487 489 3 (set (reg/v/f:SI 4 si [orig:500 W ] [500])
        (reg/v/f:SI 0 ax [orig:500 W ] [500])) "hc2cf2_16.c":691:14 85
{*movsi_internal}
     (nil))
...
(insn 491 490 474 3 (set (reg/v/f:SI 2 cx [orig:504 Im ] [504])
        (mem/f/c:SI (plus:SI (reg/f:SI 7 sp)
                (const_int 540 [0x21c])) [3 Im+0 S4 A32])) "hc2cf2_16.c":691:14
85 {*movsi_internal}
     (nil))
Now, postreload removes the useless store with uid 487 and due to the swapping
of vzeroupper pass with postreload, the good vs. bad difference before gcse is
 (insn 5 4 6 2 (set (reg/v/f:SI 4 si [orig:504 Im ] [504])
         (mem/f/c:SI (plus:SI (reg/f:SI 7 sp)
                 (const_int 540 [0x21c])) [3 Im+0 S4 A32])) "hc2cf2_16.c":456:1
85 {*movsi_internal}
-     (expr_list:REG_EQUIV (mem/f/c:SI (plus:SI (reg/f:SI 16 argp)
-                (const_int 12 [0xc])) [3 Im+0 S4 A32])
-        (nil)))
+     (expr_list:REG_UNUSED (reg/v/f:SI 4 si [orig:504 Im ] [504])
+        (expr_list:REG_EQUIV (mem/f/c:SI (plus:SI (reg/f:SI 16 argp)
+                    (const_int 12 [0xc])) [3 Im+0 S4 A32])
+            (nil))))
i.e. an extra REG_UNUSED note (on some others as well).
At that point the note is correct.
Then comes gcse and sets cx to si at the start of the bb where insn 491 used to
appear, extending the lifetime of the register, but the REG_UNUSED note is not
removed.
And then comes the pro_and_epilogue pass and because of the REG_UNUSED note
deletes the load in insn 5, even when it is now actually used.
So we are back to the PR112572 discussions.
Whether make REG_UNUSED notes only trusted in passes which explicitly request
computation of the notes problem as Richard proposed, or whether just have a
couple of passes known to screw up REG_UNUSED notes to mark them as
non-trustworthy (mainly cse/gcse/postreload-cse), or just when those passes
actually extend lifetime of something, or attempt to remove REG_UNUSED notes
actively when they extend stuff.

Reply via email to