diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-12-23 16:12:21 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-12-23 16:12:21 +0100 |
commit | fd1b0aefda5b65f3f841ca6e61ccea6a72daa060 (patch) | |
tree | c0c08e3cb221571f2716170b5d6716e5f1eeba48 /gcc/testsuite | |
parent | bd1fc4a219d8c0fad0ec41002e895b49e384c1c2 (diff) | |
download | gcc-fd1b0aefda5b65f3f841ca6e61ccea6a72daa060.zip gcc-fd1b0aefda5b65f3f841ca6e61ccea6a72daa060.tar.gz gcc-fd1b0aefda5b65f3f841ca6e61ccea6a72daa060.tar.bz2 |
tree-ssa-dom: can_infer_simple_equiv fixes [PR108068]
As reported in the PR, tree-ssa-dom.cc uses real_zerop call to find
if a floating point constant is zero and it shouldn't try to infer
equivalences from comparison against it if signed zeros are honored.
This doesn't work at all for decimal types, because real_zerop always
returns false for them (one can have different representations of decimal
zero beyond -0/+0), and it doesn't work for vector compares either,
as real_zerop checks if all elements are zero, while we need to avoid
infering equivalences from comparison against vector constants which have
at least one zero element in it (if signed zeros are honored).
Furthermore, as mentioned by Joseph, for decimal types many other values
aren't singleton.
So, this patch stops infering anything if element mode is decimal, and
otherwise uses instead of real_zerop a new function, real_maybe_zerop,
which will work even for decimal types and for complex or vector will
return true if any element is or might be zero (so it returns true
for anything but constants for now).
2022-12-23 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/108068
* tree.h (real_maybe_zerop): Declare.
* tree.cc (real_maybe_zerop): Define.
* tree-ssa-dom.cc (record_edge_info): Use it instead of
real_zerop or TREE_CODE (op1) == SSA_NAME || real_zerop. Always set
can_infer_simple_equiv to false for decimal floating point types.
* gcc.dg/dfp/pr108068.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/pr108068.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/dfp/pr108068.c b/gcc/testsuite/gcc.dg/dfp/pr108068.c new file mode 100644 index 0000000..6cbb0fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/pr108068.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/108068 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int +main () +{ + _Decimal64 x = -1; + while (x != 0) + x /= 10; + double d = x; + if (!__builtin_signbit (d)) + __builtin_abort (); +} |