https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32803
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <[email protected]>: https://gcc.gnu.org/g:74d5e928d5fe9804fdacb393d36d1be58feb60fb commit r17-494-g74d5e928d5fe9804fdacb393d36d1be58feb60fb Author: Roger Sayle <[email protected]> Date: Wed May 13 12:31:12 2026 +0100 x86: Shorter load immediate constants with -Oz This patch adds two peephole2 patterns to i386.md to decrease the size of some integer loads. These replace "movl $const, %eax" (5 bytes) with "xorl %eax, %eax" followed by either "movb $const,%al" or "movb $const,%ah" (together 4 bytes), for suitable constants and suitable general registers, when the flags register is dead. Ideally modern Intel and AMD prcoessors can recognize these sequences during instruction decode (avoiding any partial register stall in the same way they avoid the false dependence for the xorl), and internally generate a single uop, treating these bytes like an alternate instruction encoding. 2026-05-13 Roger Sayle <[email protected]> Uros Bizjak <[email protected]> gcc/ChangeLog PR target/32803 * config/i386/i386.md (peephole2): Don't transform xorl;movb into movzb with -Oz. (peephole2): Convert movl into xorl;movb (strict_low_part) with -Oz. (peephole2): Likewise, convert movl into xorl;movb [abcd]h with -Oz. gcc/testsuite/ChangeLog PR target/32803 * gcc.target/i386/pr32803-2.c: New test case. * gcc.target/i386/pr32803-3.c: Likewise.
