Tree-optimization: Fold SAT_ADD at GIMPLE level
Extends scalar SAT_ADD constant folding to recognize cases where one operand is zero.
This commit extends scalar SAT_ADD constant folding to recognize cases where one operand is zero at the GIMPLE level. By folding SAT_ADD expressions with constant operands early, it improves optimization opportunities and avoids emitting unnecessary SAT_ADD operations. This optimization can lead to more efficient code generation.
In Details
This commit introduces optimizations for SAT_ADD operations at the GIMPLE level, specifically handling cases where one operand is zero. It involves modifying fold-const-call.cc, match.pd, and genmatch.cc to recognize and fold these specific SAT_ADD patterns. The changes primarily affect the middle-end optimization passes of the compiler.
For Context
SAT_ADD refers to saturating addition, where the result is clamped to a maximum or minimum value if the true sum exceeds the representable range. GIMPLE is a simplified intermediate representation of code used within GCC to perform optimizations. Constant folding involves evaluating constant expressions at compile time, replacing the expression with its result, thereby improving performance by reducing runtime calculations.