https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98984
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Naveen H.S <[email protected]>: https://gcc.gnu.org/g:d0e28326d4254e4824096a7331c8600455c22f73 commit r17-4503-gd0e28326d4254e4824096a7331c8600455c22f73 Author: Naveen <[email protected]> Date: Sun Sep 20 22:06:57 2026 -0700 tree-optimization: Fold redundant integer-float-integer conversions [PR98984] 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]>
