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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Richard Earnshaw
<[email protected]>:

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

commit r16-10066-ge288842fc419af36fbece430b3902cdb9cafcf4e
Author: Richard Earnshaw <[email protected]>
Date:   Tue Dec 1 18:19:04 2026 +0000

    arm: fix peep2 for strd or stm of literals [PR128995]

    The sequence
            MOV  regA, const1
            MOV  regA, const2
            STR  regA, [mem]
            STR  regA, [mem+4]
    Cannot be converted into a 64-bit store of const1 and const2 because the
    first mov is really dead code (regA gets overwritten before use).  We
    wouldn't normally expect to see something like this since the
    instruction is redunant.  However, the peep2 patterns were never taught
    to expect this anomolous sequence.  There are two classes of patterns
    that need fixing.  The first class is for using strd, when available.
    The second uses stm and applies to all variants.  Improve the checks on
    the peepholes to ensure the two MOV instructions write to distinct
    registers.

    I haven't added a testcode because it would be too fragile, relying on
    the compiler not cleaning up a dead store.

    gcc/ChangeLog:

            PR target/128995
            * config/arm/arm.cc (gen_const_stm_seq): New argument unique_regs.
            If true, don't permit two regs to overlap.
            * config/arm/arm-protos.h (gen_const_stm_seq): Update prototype.
            * config/arm/ldmstm.md (peep2 patterns for stm of constants):
Update
            callers.
            * config/arm/ldrdstrd.md (peep2 for strd of constants): Ensure the
            two MOV instructions write distinct registers.

    (cherry picked from commit dee6d6cf2c2ae271ccb26b7c27d926d62c04b42e)

Reply via email to