https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128007
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <[email protected]>: https://gcc.gnu.org/g:252d2c0abfcc7633fe63ecacbc3cd535b2a58dc2 commit r17-5949-g252d2c0abfcc7633fe63ecacbc3cd535b2a58dc2 Author: Roger Sayle <[email protected]> Date: Wed Nov 4 18:15:19 2026 +0000 middle-end: PR 12800[47]: x - x may be -0.0 with FE_DOWNWARD rounding. This patch addresses PR middle-end/128004 and PR rtl-optimization/128007 which is effectively the same signed-zero and rounding-math corner case present in fold-const.cc and simplify-rtx.cc respectively. With -frounding-math and FE_DOWNWARD rounding, when x is finite (and not NaN), x - x is not +0.0 but -0.0 when honoring signed zeros (the default). 2026-11-04 Roger Sayle <[email protected]> gcc/ChangeLog PR middle-end/128004 PR rtl-optimization/128007 * fold-const.cc (const_binop): Don't fold subtractions when the exact result is known to be zero with -frounding-math when we honor signed zeros. The result is -0.0 with FE_DOWNWARD. * simplify-rtx.cc (simplify_binary_operation_1): Likewise, don't simplify x-x to +0.0 in the RTL optimizers in the same conditions. (simplify_const_binary_operation): Likewise, don't fold RTL subtractions when the exact result is zero in the same conditions. gcc/testsuite/ChangeLog PR middle-end/128004 PR rtl-optimization/128007 * gcc.dg/pr128004.c: New test case. * gcc.dg/pr128007.c: Likewise.
