Compiler Rematerialization for Register Pressure Reduction

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Compiler optimizations can increase live ranges of variables and create new variables, leading to increased register pressure and spills to memory during register allocation, which reduces processing performance.

Innovation Solution

Performing rematerialization operations on program source code before instruction scheduling to balance cross-block register pressure, thereby reducing the need for memory spills and improving processing performance.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If compiler optimizations are performed on program source code, then execution time and processing efficiency are improved, but register pressure increases leading to more spills to memory

Engineering Contradiction:
Improveexecution timeVSAvoidregister pressure
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The patent performs rematerialization analysis before instruction scheduling to proactively identify and eliminate variables that can be rematerialized. By conducting this analysis in advance, the compiler can reduce register pressure before register allocation occurs, preventing spills to memory while still achieving execution time optimizations through subsequent instruction scheduling and optimization passes.

Inventive Principle:
Principle #10Preliminary action

2Productivity

If rematerialization operations are performed after instruction scheduling, then instruction optimization is improved, but register pressure at block boundaries remains high causing memory spills

Engineering Contradiction:
Improveinstruction optimizationVSAvoidregister pressure at block boundary
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The patent shifts the rematerialization analysis to occur before instruction scheduling rather than after. This preliminary timing allows the compiler to identify variables suitable for rematerialization before the instruction scheduling process creates additional register pressure at block boundaries, thereby preventing memory spills while still enabling effective instruction optimization.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent divides the compilation process into distinct phases with rematerialization analysis occurring as a separate preliminary step before instruction scheduling. This segmentation allows independent optimization of register pressure reduction and instruction scheduling, enabling each phase to operate effectively without interfering with the other.

Inventive Principle:
Principle #1Segmentation

3Adaptability or versatility

If more variables are created during compiler optimization, then program functionality is enhanced, but register allocation becomes more difficult increasing memory spills

Engineering Contradiction:
Improveprogram functionalityVSAvoidregister allocation complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent identifies variables that can be discarded from register allocation by rematerializing them at their use sites. Instead of allocating registers for all created variables, the compiler recovers register space by computing values on-demand where needed, thereby reducing register allocation complexity and memory spills while preserving full program functionality.

Inventive Principle:
Principle #34Discarding and recovering

Data Source

PatentEP4062276B1Pre-instruction scheduling rematerialization for register pressure reduction
Publication Date: 2025.01.22 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP4062276B1 patent drawingFigure 1
  • EP4062276B1 patent drawingFigure 2
  • EP4062276B1 patent drawingFigure 3

AI summary

Examples are disclosed herein that relate to performing rematerialization operation(s) on program source code prior to instruction scheduling. In one example, a method includes prior to performing instruction scheduling on program source code, for each basic block of the program source code, determining a register pressure at a boundary of the basic block, determining whether the register pressure at the boundary is greater than a target register pressure, based on the register pressure at the boundary being greater than the target register pressure, identifying one or more candidate instructions in the basic block suitable for rematerialization to reduce the register pressure at the boundary, and performing a rematerialization operation on at least one of the one or more candidate instructions to reduce the register pressure at the boundary to be less than the target register pressure.