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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <[email protected]>:

https://gcc.gnu.org/g:f73b1b0831fe8f071761cc2c6696d92e258d2b4f

commit r16-5514-gf73b1b0831fe8f071761cc2c6696d92e258d2b4f
Author: Jeff Law <[email protected]>
Date:   Sat Nov 22 11:33:57 2025 -0700

    [PR 122701] Emit fresh reg->reg copy rather than modifying existing insnO

    I took an ill-advised short-cut with the recent ext-dce improvement to
detect
    certain shift pairs as sign/zero extensions.  Specifically I was adjusting
the
    SET_SRC of an object.

    Often we can get away with that, but as this case shows it's simply not
safe
    for RTL.  The core issue is the right shift we're modifying into a simple
    reg->reg move may have things like CLOBBERs outside the set resulting in

    (parallel
      (set (dstreg) (srcreg))
      (clobber (whatever)))

    Even that is often OK as targets which have these kinds of clobbers often
need them on their basic moves because those moves often set condition codes. 
But that's not true for GCN.

    On GCN that transformation leads to an unrecognizable insn as seen in the
pr.
    The fix is pretty simple.  Just emit a new move and delete the shift.  Of
    course we have to be prepared to handle multiple insns once we use
    emit_move_insn, but that's not too bad.

            PR rtl-optimization/122701
    gcc/
            * ext-dce.cc (ext_dce_try_optimize_rshift): Emit a fresh reg->reg
            copy rather than modifying the existing right shift.

    gcc/testsuite/
            * gcc.dg/torture/pr122701.c: New test.

Reply via email to