aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-06-14 09:38:47 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-06-14 09:38:47 +0000
commit7579786c459a4acb3be7624e606828e6a2439857 (patch)
tree0d189f4a5a6e38611ead406bf5126ee7e952348a
parent7670292377f3b4bebb14d9d5aa29e72933e05c94 (diff)
downloadgcc-7579786c459a4acb3be7624e606828e6a2439857.zip
gcc-7579786c459a4acb3be7624e606828e6a2439857.tar.gz
gcc-7579786c459a4acb3be7624e606828e6a2439857.tar.bz2
vrp.h: New testcase.
2012-06-14 Richard Guenther <rguenther@suse.de> * gcc.dg/tree-ssa/vrp.h: New testcase. * gcc.dg/tree-ssa/vrp68.c: Likewise. From-SVN: r188604
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp.h27
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp68.c24
3 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 74e8314..2360767 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-14 Richard Guenther <rguenther@suse.de>
+
+ * gcc.dg/tree-ssa/vrp.h: New testcase.
+ * gcc.dg/tree-ssa/vrp68.c: Likewise.
+
2012-06-13 Christian Bruel <christian.bruel@st.com>
PR target/53621
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp.h b/gcc/testsuite/gcc.dg/tree-ssa/vrp.h
new file mode 100644
index 0000000..079013a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp.h
@@ -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)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp68.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp68.c
new file mode 100644
index 0000000..291b376
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp68.c
@@ -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" } } */