Landing: 74d5e928d5fe
Project / Subsystem
gcc / x86
Date
2026-05-13
Author
Roger Sayle
Commit
74d5e928d5fe9804fdacb393d36d1be58feb60fb
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- x86
- patch_id
- —
- commit_hash
- 74d5e928d5fe9804fdacb393d36d1be58feb60fb
- source_type
- github
- headline
- x86: Generate shorter load-immediate constants with -Oz.
- tldr
- This change reduces code size on x86 by using `xorl` and `movb` to load small constants, replacing larger `movl` instructions at -Oz.
- author
- Roger Sayle
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • x86
- • optimization
- • code size
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-13T00:00:00.000Z
This commit introduces peephole optimizations for x86 that reduce code size when compiling with -Oz (optimize for size). It replaces movl $const, %eax (5 bytes) with an xorl %eax, %eax followed by a movb $const,%al or movb $const,%ah (4 bytes total) sequence when the flags register is dead. This optimization applies when loading small integer constants into suitable general-purpose registers, resulting in smaller executables.