]> gcc.gnu.org Git - gcc.git/commit
[PATCH] PR tree-optimization/104420: Fix checks for constant folding X*0.0
authorRoger Sayle <roger@nextmovesoftware.com>
Wed, 9 Feb 2022 14:21:08 +0000 (14:21 +0000)
committerRoger Sayle <roger@nextmovesoftware.com>
Wed, 9 Feb 2022 14:23:17 +0000 (14:23 +0000)
commit2d3c477599b02b06e338acd5f5098ee7a3fe6176
tree8b4b47886d584fd019a8e03583e4ce58ed66f84b
parentbe9cd0ca8a5f13cfee6a39b217d439a25c53553a
[PATCH] PR tree-optimization/104420: Fix checks for constant folding X*0.0

This patch resolves PR tree-optimization/104420, which is a P1 regression
where, as observed by Jakub Jelinek, the conditions for constant folding
x*0.0 are incorrect (following my patch for PR tree-optimization/96392).
The multiplication x*0.0 may yield a negative zero result, -0.0, if X is
negative (not just if x may be negative zero).  Hence (without -ffast-math)
(int)x*0.0 can't be optimized to 0.0, but (unsigned)x*0.0 can be constant
folded.  This adds a bunch of test cases to confirm the desired behaviour,
and removes an incorrect test from gcc.dg/pr96392.c which checked for the
wrong behaviour.

2022-02-09  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR tree-optimization/104420
* match.pd (mult @0 real_zerop): Tweak conditions for constant
folding X*0.0 (or X*-0.0) to HONOR_SIGNED_ZEROS when appropriate.

gcc/testsuite/ChangeLog
PR tree-optimization/104420
* gcc.dg/pr104420-1.c: New test case.
* gcc.dg/pr104420-2.c: New test case.
* gcc.dg/pr104420-3.c: New test case.
* gcc.dg/pr104420-4.c: New test case.
* gcc.dg/pr96392.c: Remove incorrect test.
gcc/match.pd
gcc/testsuite/gcc.dg/pr104420-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr104420-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr104420-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr104420-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr96392.c
This page took 0.077735 seconds and 6 git commands to generate.