public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "hernandez, aldy" <aldyh@redhat.com>
Subject: [COMMITTED] Add 3 floating NAN tests.
Date: Mon, 17 Oct 2022 09:25:59 -0400	[thread overview]
Message-ID: <65c19cf9-5709-3be3-5cd4-7a75dbd53c6a@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 147 bytes --]

3 tests from Aldy using the relations generated by GORI between operands 
to set or clear NANs as appropriate on outgoing edges.

Pushed.

Andrew


[-- Attachment #2: 0004-Add-3-floating-NAN-tests.patch --]
[-- Type: text/x-patch, Size: 2779 bytes --]

From 7896a31d3003bad8b845881f59e570fbc3c78cfa Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@redhat.com>
Date: Mon, 10 Oct 2022 11:01:48 +0200
Subject: [PATCH 4/4] 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.
---
 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(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vrp-float-3a.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vrp-float-4a.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vrp-float-5a.c

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" } }
-- 
2.37.3


                 reply	other threads:[~2022-10-17 13:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65c19cf9-5709-3be3-5cd4-7a75dbd53c6a@redhat.com \
    --to=amacleod@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).