aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-09-20 16:19:14 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-09-21 11:06:57 +0200
commitd2278da1c3cb7bf8b3d96c86dbef2982bf4cc54a (patch)
treebc0bd39f8caa2202ec73ca9e4bf8cd4655c2c4b3 /gcc/testsuite
parentce8aed75a38b468490ecab4c318e3eb08d468608 (diff)
downloadgcc-d2278da1c3cb7bf8b3d96c86dbef2982bf4cc54a.zip
gcc-d2278da1c3cb7bf8b3d96c86dbef2982bf4cc54a.tar.gz
gcc-d2278da1c3cb7bf8b3d96c86dbef2982bf4cc54a.tar.bz2
[PR106967] frange: revamp relational operators for NANs.
Since NANs can be inserted by other passes even for -ffinite-math-only, we can't depend on the flag to determine if a NAN is a possiblity. Instead, we must explicitly check for them. In the case of -ffinite-math-only, paths leading up to a NAN are undefined and can be considered unreachable. I have audited all the relational code and made sure we're handling the known NAN case before anything else, setting undefined when appropriate. In the process, I revamped all the relational code handling NANs to correctly notice paths that are unreachable. The basic structure for ordered relational operators (except != of course) is this: If either operand is a known NAN, return FALSE. The true side of a relop when one operand is a NAN is unreachable. On the false side of a relop when one operand is a NAN, we know nothing about the other operand. Regstrapped on x86-64 and ppc64le Linux. lapack testing on x86-64 with and without -ffinite-math-only. PR tree-optimization/106967 gcc/ChangeLog: * range-op-float.cc (foperator_equal::fold_range): Adjust for NAN. (foperator_equal::op1_range): Same. (foperator_not_equal::fold_range): Same. (foperator_not_equal::op1_range): Same. (foperator_lt::fold_range): Same. (foperator_lt::op1_range): Same. (foperator_lt::op2_range): Same. (foperator_le::fold_range): Same. (foperator_le::op1_range): Same. (foperator_le::op2_range): Same. (foperator_gt::fold_range): Same. (foperator_gt::op1_range): Same. (foperator_gt::op2_range): Same. (foperator_ge::fold_range): Same. (foperator_ge::op1_range): Same. (foperator_ge::op2_range): Same. (foperator_unordered::op1_range): Same. (foperator_ordered::fold_range): Same. (foperator_ordered::op1_range): Same. (build_le): Assert that we don't have a NAN. (build_lt): Same. (build_gt): Same. (build_ge): Same. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr106967.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr106967.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr106967.c b/gcc/testsuite/gcc.dg/tree-ssa/pr106967.c
new file mode 100644
index 0000000..bff2795
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr106967.c
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-options "-O2 -ffinite-math-only -fno-trapping-math -fno-tree-dominator-opts" }
+
+void
+foo (float x, int *y)
+{
+ int i;
+ float sum2 = 0.0;
+
+ for (i = 0; i < *y; ++i)
+ sum2 += x;
+
+ sum2 = 1.0 / sum2;
+ if (sum2 * 0.0 < 5.E-5)
+ *y = 0;
+}