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 testcases resolved with ranger as VRP1.
Date: Thu, 3 Nov 2022 15:28:59 -0400	[thread overview]
Message-ID: <8fb928cd-2a2d-3de5-9f33-08918dc9bac5@redhat.com> (raw)

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

Turning ranger on by default for the VRP1 pass fixed 3 outstanding PRs:

93917, 999966, and 102650.   Adding testcases for those PRs.

Andrew

[-- Attachment #2: 0001-Add-testcases-resolved-with-ranger-as-VRP1.patch --]
[-- Type: text/x-patch, Size: 2540 bytes --]

From 863f50c84be7302ba14ce650838e3fd475b0cd56 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Thu, 3 Nov 2022 13:07:33 -0400
Subject: [PATCH] Add testcases resolved with ranger as VRP1.

	gcc/testsuite/
	* g++.dg/pr99966.C: New.
	* gcc.dg/pr93917.c: New.
	* gcc.dg/pr102650.c: New.
---
 gcc/testsuite/g++.dg/pr99966.C  | 23 +++++++++++++++++++++++
 gcc/testsuite/gcc.dg/pr102650.c | 20 ++++++++++++++++++++
 gcc/testsuite/gcc.dg/pr93917.c  | 20 ++++++++++++++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/pr99966.C
 create mode 100644 gcc/testsuite/gcc.dg/pr102650.c
 create mode 100644 gcc/testsuite/gcc.dg/pr93917.c

diff --git a/gcc/testsuite/g++.dg/pr99966.C b/gcc/testsuite/g++.dg/pr99966.C
new file mode 100644
index 00000000000..4d689822b87
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr99966.C
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-require-effective-target c++17 }
+// { dg-options "-O2 -fdump-tree-vrp1" }
+
+// Test we can remove a range bound after the assert.
+
+#include <cassert>
+#include <cstdint>
+#include <cstddef>
+#include <vector>
+
+uint64_t f(std::vector<uint64_t>& data, size_t start, size_t end){
+    assert(start < end && start < data.size() && end <= data.size());
+
+
+    uint64_t total = 0;
+    for (size_t i = start; i < end; i++) {
+        total += data.at(i);
+    }
+    return total;
+}
+
+/* { dg-final { scan-tree-dump-not "throw" "vrp1"} } */
diff --git a/gcc/testsuite/gcc.dg/pr102650.c b/gcc/testsuite/gcc.dg/pr102650.c
new file mode 100644
index 00000000000..16ae840260f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102650.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-vrp1" } */
+
+static int a = 2, b, c, d;
+void foo(void);
+int main() {
+    short e;
+    int f = -1;
+    if (b)
+        c = 0;
+    c || (f = 2);
+    for (; d < 1; d++)
+        e = f + a;
+    if (!e)
+        foo();
+    return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "foo" "vrp1" } } */
+
diff --git a/gcc/testsuite/gcc.dg/pr93917.c b/gcc/testsuite/gcc.dg/pr93917.c
new file mode 100644
index 00000000000..41d27fb9a8f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr93917.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+void f3(int n);
+
+void f1(int n)
+{
+  if(n<0)
+    __builtin_unreachable();
+  f3(n);
+}
+
+void f2(int*n)
+{
+  if(*n<0)
+    __builtin_unreachable();
+  f3 (*n);
+}
+
+/* { dg-final { scan-tree-dump-times "Global Exported" 2 "vrp1" } } */
-- 
2.37.3


                 reply	other threads:[~2022-11-03 19:29 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=8fb928cd-2a2d-3de5-9f33-08918dc9bac5@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).