diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2022-08-29 17:52:20 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2022-08-30 11:26:24 +0200 |
commit | df8fe4adb0721ab0e4486bc58482b501fe06287d (patch) | |
tree | 57f8aa32e21771f4d329930f4525d926177317e6 /gcc/value-range-pretty-print.cc | |
parent | 34ad7155fe2a4a5d0b1815c79ce8b2af4c772c9e (diff) | |
download | gcc-df8fe4adb0721ab0e4486bc58482b501fe06287d.zip gcc-df8fe4adb0721ab0e4486bc58482b501fe06287d.tar.gz gcc-df8fe4adb0721ab0e4486bc58482b501fe06287d.tar.bz2 |
A == 0 ? A : -A same as -A (when A is 0.0)
The upcoming work for frange triggers a regression in
gcc.dg/tree-ssa/phi-opt-24.c.
For -O2 -fno-signed-zeros, we fail to transform the following into -A:
float f0(float A)
{
// A == 0? A : -A same as -A
if (A == 0) return A;
return -A;
}
This is because the abs/negative match.pd pattern here:
/* abs/negative simplifications moved from fold_cond_expr_with_comparison,
Need to handle (A - B) case as fold_cond_expr_with_comparison does.
Need to handle UN* comparisons.
...
...
Sees IL that has the 0.0 propagated.
Instead of:
<bb 2> [local count: 1073741824]:
if (A_2(D) == 0.0)
goto <bb 4>; [34.00%]
else
goto <bb 3>; [66.00%]
<bb 3> [local count: 708669601]:
_3 = -A_2(D);
<bb 4> [local count: 1073741824]:
# _1 = PHI <A_2(D)(2), _3(3)>
It now sees:
<bb 4> [local count: 1073741824]:
# _1 = PHI <0.0(2), _3(3)>
which it leaves untouched, causing the if conditional to survive.
Changing integger_zerop to zerop fixes the problem.
I did not include a testcase, as it's just phi-opt-24.c which will get
triggered when I commit the frange with endpoints work.
gcc/ChangeLog:
* match.pd ((cmp @0 zerop) real_zerop (negate@1 @0)): Add variant
for real zero.
Diffstat (limited to 'gcc/value-range-pretty-print.cc')
0 files changed, 0 insertions, 0 deletions