GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
match.pd Performance Win

Fold nested CPROJ inside CPROJ or CABS.

Optimized folding of complex number operations improves code generation.

This commit enhances the match.pd optimization pass by introducing patterns to fold complex projection (CPROJ) operations when they are nested within other CPROJ or complex absolute value (CABS) operations. This resolves an issue in GIMPLE SSA where nested calls were not being optimized, leading to less efficient code generation. A new test case verifies the correct folding.

In Details

The match.pd pass in GCC's tree-ssa optimization pipeline has been updated with new patterns to handle nested __builtin_cproj and __builtin_cabs calls. Previously, the optimizer might not have recognized that the result of an outer cproj or cabs could be folded directly, potentially leaving redundant calls in the GIMPLE representation. These new patterns allow the optimizer to simplify such constructs, reducing redundant computations.

For Context
CPROJ
Represents the cproj intrinsic function, which computes the projection of a complex number onto the Riemann sphere. This is used to handle infinities and NaNs in complex arithmetic.
CABS
Represents the cabs intrinsic function, which computes the absolute value (or magnitude) of a complex number.
GIMPLE SSA
An intermediate representation (IR) used by GCC. It is based on Gimple statements and uses Static Single Assignment (SSA) form, which makes optimizations easier by ensuring each variable is assigned a value only once.
tree-ssa optimization
A phase in GCC's compilation pipeline that performs various optimizations on the 'tree' intermediate representation after it has been converted to SSA form. This includes constant folding, dead code elimination, and more complex transformations.
Filed Under: optimizationcomplex numbers