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

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

https://gcc.gnu.org/g:60b27d915e14748a627deb1a4616da419b1e24b2

commit r17-2486-g60b27d915e14748a627deb1a4616da419b1e24b2
Author: Uros Bizjak <[email protected]>
Date:   Fri Jul 17 13:28:16 2026 +0200

    i386: Add ROLW %r,8 alternative to bswaphi2 patterns [PR126283]

    The HImode bswap can be implemented in two ways: using XCHGB %rH,%rL or
    ROLW %r,8 where the former does not clobber flags.  Unfortunately,
clobber-less
    XCHGB form limits available register set to only %ax, %bx, %cx and %dx,
where
    ROLW can use all registers (but clobbers flags reg).

    It is better to use the form that clobbers flags reg and leave insn
selection
    to the compiler via preferred_for_* machinery.  This choice also makes
    "improve register allocation" peephole2 obsolete.

    Also, always convert HImode rotate by 8 to bswap pattern, which can also
    emit MOVBE instruction when available.

            PR target/126283

    gcc/ChangeLog:

            * config/i386/i386.md (bswaphi2): Add flags reg clobber.
            (*bswaphi2_movbe): Add flags reg clobber.  Add ROLW alternative
            and update instruction attributes.  Add preferred_for_size and
            preferred_for_speed attributes.
            (*bswaphi2): Ditto.
            (*bswaphisi2_lowpart): Ditto.
            (XCHGB -> ROLW peephole2 patterns): Remove.
            (ROLW reg,8 -> BSWAP splitter): Update for added flags reg clobber.
            Always split.
            * config/i386/i386-expand.cc (ix86_expand_gfni_bitreverse):
            Update for bswaphi2 change.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/xchg-1.c: Scan for XCHG instead of ROL.
            * gcc.target/i386/pr126283.c: New test.

Reply via email to