public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3334] Add 3 floating NAN tests.
@ 2022-10-17 13:25 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2022-10-17 13:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7896a31d3003bad8b845881f59e570fbc3c78cfa

commit r13-3334-g7896a31d3003bad8b845881f59e570fbc3c78cfa
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Oct 10 11:01:48 2022 +0200

    Add 3 floating NAN tests.
    
    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.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/vrp-float-3a.c | 19 +++++++++++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/vrp-float-4a.c | 23 +++++++++++++++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/vrp-float-5a.c | 16 ++++++++++++++++
 3 files changed, 58 insertions(+)

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
index 00000000000..5aadaa7c4db
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-3a.c
@@ -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
index 00000000000..7d3187b3962
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-4a.c
@@ -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
index 00000000000..08332305f2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-5a.c
@@ -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" } }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-17 13:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17 13:25 [gcc r13-3334] Add 3 floating NAN tests Andrew Macleod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).