public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Testcase for VRP range-anti-range merging
Date: Thu, 14 Jun 2012 09:40:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1206141136240.19312@zhemvz.fhfr.qr> (raw)


Tested on x86_64-unknown-linux-gnu, applied.

Richard.

2012-06-14  Richard Guenther  <rguenther@suse.de>

	* gcc.dg/tree-ssa/vrp.h: New testcase.
	* gcc.dg/tree-ssa/vrp68.c: Likewise.

Index: gcc/testsuite/gcc.dg/tree-ssa/vrp.h
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/vrp.h	(revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/vrp.h	(revision 0)
@@ -0,0 +1,27 @@
+extern void link_error(void);
+
+#define RANGE(name, min, max) \
+  if (name < min || name > max) \
+    return;
+#define ANTI_RANGE(name, min, max) \
+  if (name >= min && name <= max) \
+    return;
+#define MERGE(cond, name1, name2) \
+  if (cond) \
+    name1 = name2;
+#define CHECK_RANGE(expr, min, max) \
+  do { \
+     __typeof__ (expr) v = (expr); \
+     if (v < min) link_error(); \
+     if (v > max) link_error(); \
+     if (v < min || v > max) link_error (); \
+  } while (0) 
+#define CHECK_ANTI_RANGE(expr, min, max) \
+  do { \
+    __typeof__ (expr) v = (expr); \
+    if (v >= min) \
+      if (v <= max) \
+        link_error(); \
+    if (v >= min && v <= max) \
+      link_error(); \
+  } while (0)
Index: gcc/testsuite/gcc.dg/tree-ssa/vrp68.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/vrp68.c	(revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/vrp68.c	(revision 0)
@@ -0,0 +1,24 @@
+/* { dg-do link } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+#include "vrp.h"
+
+void test1 (int i, int j, int b)
+{
+  RANGE(i, 2, 6);
+  ANTI_RANGE(j, 1, 7);
+  MERGE(b, i, j);
+  CHECK_ANTI_RANGE(i, 7, 7);
+  CHECK_ANTI_RANGE(i, 1, 1);
+  /* If we swap the anti-range tests the ~[6, 6] test is never eliminated.  */
+}
+int main() { }
+
+/* While subsequent VRP/DOM passes manage to even recognize the ~[6, 6]
+   test as redundant a single VRP run will arbitrarily choose ~[0, 0] when
+   merging [1, 5] with ~[0, 6] so the first VRP pass can only eliminate
+   the ~[0, 0] check as redundant.  */
+
+/* { dg-final { scan-tree-dump-times "vrp1" 0 "link_error" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vrp1" 1 "link_error" } } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */

                 reply	other threads:[~2012-06-14  9:38 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=alpine.LNX.2.00.1206141136240.19312@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --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).