On 9/9/26 6:40 AM, Naveen wrote:
GCC eliminates an integer-to-floating-point-to-integer conversion when the
intermediate floating-point type can represent every value of the input
integer type. This misses cases where it can represent every value of the
final integer type.
Extend the existing PR66211 folding pattern to use the final integer precision
as an alternative condition when -fno-trapping-math is enabled. Values in
range are represented exactly while out-of-range conversions are already
undefined or invalid, so removing the intermediate conversion is safe.
gcc/ChangeLog:
PR tree-optimization/98984
* match.pd: Fold integer-float-integer conversions when the
intermediate floating-point significand covers the final integer
precision under -fno-trapping-math.
gcc/testsuite/ChangeLog:
PR tree-optimization/98984
* gcc.dg/tree-ssa/pr98984.c: New test.
* gcc.dg/tree-ssa/pr98984-2.c: New test.
Signed-off-by: Naveen <[email protected]>
OK for the trunk. Sorry for the long delay.
Jeff