Fold redundant integer-float-integer conversions
Optimizes redundant int->float->int conversions when precision is maintained.
This optimization folds redundant integer-to-floating-point-to-integer conversions when the intermediate floating-point type can precisely represent all values of the final integer type. This improves code efficiency by eliminating unnecessary conversions, especially when the -fno-trapping-math option is enabled and the floating-point significand has sufficient precision.
In Details
The pattern in match.pd has been extended to fold integer-float-integer conversions if the intermediate floating-point type's significand can exactly represent all values of the final integer type, provided -fno-trapping-math is in effect. This builds upon the existing pattern from PR66211, safely removing the intermediate floating-point conversion when precision is guaranteed, thus addressing PR98984.
- tree-optimization
- A stage in GCC optimization where the code is represented in an intermediate form called GENERIC/GIMPLE (a three-address code representation) before being converted to RTL.
- folding
- An optimization technique where constant expressions or redundant operations are evaluated or removed at compile time.
- significand
- The fractional part of a floating-point number, also known as the mantissa.
- -fno-trapping-math
- A compiler flag that modifies floating-point exception handling; when enabled, operations like division by zero or overflow do not raise exceptions but result in undefined or special values, allowing for more aggressive optimizations.
- PR
- Problem Report, used to refer to specific bugs or feature requests filed against GCC.