GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
combine Performance Win

Improve combine pass to optimize field assignments with addition

Optimizes field assignments involving addition, reducing generated code.

The combine pass now correctly optimizes assignments to bitfields that use addition, similar to how it handles bitwise OR and XOR. This optimization, particularly relevant for the i386 architecture, can significantly reduce generated code by allowing direct byte manipulation instead of intermediate register operations. A new test case demonstrates the improvement for a common scenario.

In Details

The make_field_assignment function within combine.cc previously optimized assignments to bitfields only when the operation was IOR or XOR. This patch extends that logic to include PLUS. For instance, on i386 with -m32 -O2, code like x = (x & 0xFFFFFF00) + (unsigned int)c; now correctly compiles to movb %al, x instead of performing intermediate additions and moves. This aligns the optimization with behavior seen for bitwise operations and addresses issues like PR target/15184.

For Context
combine pass
A GCC optimization pass that performs various local transformations and constant folding on the GIMPLE intermediate representation.
bitfield
A structure member that occupies a specified number of bits, which can be less than the size of a full data type.
i386
The Intel 80386 microprocessor architecture, a 32-bit extension of the earlier x86 architecture, commonly used as a target for compilation.
Filed Under: optimizationcombinei386bugfix