GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc Performance Win

Fix soft conflict and hard register cost calculation

Corrects the use of conflict allocno mode when finding soft conflicts in IRA, improving code generation.

This commit corrects an error in GCC’s Intermediate Representation Allocator (IRA) that occurred when identifying soft register conflicts. The code was incorrectly using the conflict allocation number mode, which could lead to increased shuffling of data between registers at region borders, resulting in suboptimal code generation. By using the correct allocation number mode, the patch aims to reduce unnecessary data movement and improve the overall quality of the generated code.

In Details

When performing register allocation, IRA identifies both hard (impossible to allocate the same register) and soft (undesirable but possible) conflicts between variables. When resolving soft conflicts, the code in ira-color.cc's assign_hard_reg function was incorrectly using the conflict allocno mode when calling note_conflict. This could result in suboptimal register assignments and increased shuffling at region boundaries. This commit corrects this by using the correct allocno mode, improving register allocation and potentially leading to better code generation.

For Context

During compilation, the register allocator tries to assign program variables to CPU registers. Registers are fast, but limited, so the allocator must resolve conflicts when two variables need the same register at the same time. Sometimes a conflict can be resolved by moving data between registers (shuffling). This commit fixes a bug in GCC's register allocator that was causing it to make suboptimal decisions about when to shuffle data, leading to less efficient code. By correcting how conflicts are handled, the compiler can now generate slightly faster code in some cases.

Filed Under: gccIRAregister allocationoptimization