]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add 3 floating NAN tests.
authorAldy Hernandez <aldyh@redhat.com>
Mon, 10 Oct 2022 09:01:48 +0000 (11:01 +0200)
committerAndrew MacLeod <amacleod@redhat.com>
Mon, 17 Oct 2022 13:23:05 +0000 (09:23 -0400)
x UNORD x should set NAN on the TRUE side.
The false side of x == x should set NAN.
The true side of x != x should set NAN.

gcc/testsuite/
* gcc.dg/tree-ssa/vrp-float-3a.c: New.
* gcc.dg/tree-ssa/vrp-float-4a.c: New.
* gcc.dg/tree-ssa/vrp-float-5a.c: New.

gcc/testsuite/gcc.dg/tree-ssa/vrp-float-3a.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp-float-4a.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp-float-5a.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-3a.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-3a.c
new file mode 100644 (file)
index 0000000..5aadaa7
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile }
+// { dg-options "-O2 -fno-thread-jumps -fdisable-tree-fre1 -fdump-tree-evrp" }
+
+void link_error ();
+void bar ();
+
+float
+foo (float x)
+{
+  if (x != x)
+    {
+      // The true side of x != x implies NAN, so we should be able to
+      // fold this.
+      if (!__builtin_isnan (x))
+       link_error ();
+    }
+}
+
+// { dg-final { scan-tree-dump-not "link_error" "evrp" } }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-4a.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-4a.c
new file mode 100644 (file)
index 0000000..7d3187b
--- /dev/null
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-O2 -fno-thread-jumps -fdisable-tree-fre1 -fdump-tree-evrp" }
+
+void link_error ();
+void bar ();
+
+float
+foo (float x)
+{
+  if (x == x)
+    {
+      bar ();
+    }
+  else
+    {
+      // The false side of x == x implies NAN, so we should be able to
+      // fold this.
+      if (!__builtin_isnan (x))
+       link_error ();
+    }
+}
+
+// { dg-final { scan-tree-dump-not "link_error" "evrp" } }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-5a.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-5a.c
new file mode 100644 (file)
index 0000000..0833230
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-options "-O2 -fno-thread-jumps -fdisable-tree-fre1 -fdump-tree-evrp" }
+
+void link_error ();
+
+float
+foo (float x)
+{
+  if (__builtin_isnan (x))
+    {
+      if (!__builtin_isnan (x))
+       link_error ();
+    }
+}
+
+// { dg-final { scan-tree-dump-not "link_error" "evrp" } }