GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gimple

Fix factor_operation_ok's type matching for functions

Correctly matches types for function operations in GIMPLE to prevent incorrect early exits.

This commit corrects the factor_operation_ok function in GIMPLE by ensuring type matching occurs before function checks. Previously, the code could exit prematurely for certain functions, leading to incorrect optimization. The change also modifies argument checks to prevent similar early exits in the future, improving the robustness of operation factoring.

In Details

The factor_operation_ok function in gimple-match-exports.cc is responsible for determining if an operation can be factored out. This change reorders checks to prioritize type compatibility before evaluating function-specific conditions, preventing erroneous early returns. It also refactors the function argument check to avoid similar premature exits, ensuring more consistent behavior for factoring operations across various built-in functions.

For Context
GIMPLE
GCC's internal three-address code representation, used for optimization passes. It's a simplified intermediate representation derived from the compiler's parse tree.
factor_operation_ok
A function within GCC's GIMPLE matching logic that checks if an operation is suitable for factoring or simplification.
Filed Under: optimizationgimple