diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-09 14:03:10 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-09 14:03:10 +0000 |
commit | 63bb6dcffb53e4b4ddf8cd588774e3a8c4f66f6b (patch) | |
tree | 65bbb1ea81207fe1b61b32ed9e44238c8a15c344 /gcc/testsuite | |
parent | 720c86a2be55304efadd1a4ed22e5aa61b3ae7a3 (diff) | |
download | gcc-63bb6dcffb53e4b4ddf8cd588774e3a8c4f66f6b.tar.gz |
2011-08-09 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (zero_nonzero_bits_from_vr): Also return precise
information for ranges with only negative values.
(extract_range_from_binary_expr_1): Adjust BIT_IOR_EXPR and
BIT_AND_EXPR handling to handle ranges with negative values.
* gcc.dg/tree-ssa/vrp57.c: Disable CCP.
* gcc.dg/tree-ssa/vrp60.c: New testcase.
* gcc.dg/tree-ssa/vrp61.c: Likewise.
* gcc.dg/tree-ssa/vrp62.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177597 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp57.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp60.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp61.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp62.c | 110 |
5 files changed, 165 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d3e94197493..ba435362e6f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-08-09 Richard Guenther <rguenther@suse.de> + + * gcc.dg/tree-ssa/vrp57.c: Disable CCP. + * gcc.dg/tree-ssa/vrp60.c: New testcase. + * gcc.dg/tree-ssa/vrp61.c: Likewise. + * gcc.dg/tree-ssa/vrp62.c: Likewise. + 2011-08-09 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> * gfortran.dg/scratch_1.f90: Skip on spu-*-*. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp57.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp57.c index c736adc9e3e..cac37835dac 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp57.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp57.c @@ -1,6 +1,6 @@ /* PR40052 */ /* { dg-do compile } */ -/* { dg-options "-O -ftree-vrp -fdump-tree-optimized" } */ +/* { dg-options "-O -ftree-vrp -fno-tree-ccp -fdump-tree-optimized" } */ int foo(_Bool b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp60.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp60.c new file mode 100644 index 00000000000..9b34e3d492d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp60.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-ccp -fno-tree-dominator-opts -fdump-tree-vrp1" } */
+
+int foo (int x, int b)
+{
+ int cst;
+ if (b)
+ cst = -__INT_MAX__ - 1;
+ else
+ cst = -__INT_MAX__;
+ x = x | cst;
+ if (x >= 0)
+ return 12345;
+ return x;
+}
+
+int bar (int x, int b)
+{
+ int cst;
+ if (b)
+ cst = __INT_MAX__;
+ else
+ cst = __INT_MAX__ - 1;
+ x = x & cst;
+ if (x < 0)
+ return 12345;
+ return x;
+}
+
+/* { dg-final { scan-tree-dump-not "12345" "vrp1" } } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp61.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp61.c new file mode 100644 index 00000000000..93bcbc9151d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp61.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1" } */ + +int f (int x, int y) +{ + if (x > -1024 && x < 0 && y > -1024 && y < 0) + { + x = x ^ y; + if (x < 0 || x > 1023) + return 1234; + } + return x; +} + +/* { dg-final { scan-tree-dump-not "1234" "vrp1" } } */ +/* { dg-final { cleanup-tree-dump "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp62.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp62.c new file mode 100644 index 00000000000..139195b1e51 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp62.c @@ -0,0 +1,110 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-ccp -fno-tree-dominator-opts" } */ + +/* Tests generated via */ + +#if 0 +#include <stdio.h> +int main(int argc, char **argv) +{ + int amin, amax, bmin, bmax, a, b; + int testno = 0; + int min = atoi (argv[1]); + int max = atoi (argv[2]); + char op = argv[3][0]; + printf ("/* Testing range [%d, %d] with operator %c. */\n", min, max, op); + printf ("extern void abort (void);\n"); + for (amin = min; amin <= max; ++amin) + for (amax = amin; amax <= max; ++amax) + for (bmin = min; bmin <= max; ++bmin) + for (bmax = bmin; bmax <= max; ++bmax) + { + ++testno; + printf ("int test%d (int a, int b)\n" + "{\n" + " if (a >= %d && a <= %d && b >= %d && b <= %d)\n" + " {\n" + " int x = a %c b;\n" + " if (0\n", testno, amin, amax, bmin, bmax, op); + for (a = amin; a <= amax; ++a) + for (b = bmin; b <= bmax; ++b) + printf ("|| x == (%d %c %d)\n", a, op, b); + printf (" ) return 0;\n" + " abort ();\n" + " }\n" + " return 0;\n" + "}\n"); + } + printf ("int main()\n" + "{\n" + " int a, b;\n" + " for (a = %d; a <= %d; ++a)\n" + " for (b = %d; b <= %d; ++b)\n" + " {\n", min, max, min, max); + for (; testno > 0; --testno) + printf (" test%d (a, b);\n", testno); + printf (" }\n" + " return 0;\n" + "}\n"); + return 0; +} +#endif + +extern void abort (void); + +int test381 (int a, int b) +{ + if (a >= -3 && a <= -1 && b >= -2 && b <= 3) + { + int x = a | b; + if (x == (-3 | -2) + || x == (-3 | -1) + || x == (-3 | 0) + || x == (-3 | 1) + || x == (-3 | 2) + || x == (-3 | 3) + || x == (-2 | -2) + || x == (-2 | -1) + || x == (-2 | 0) + || x == (-2 | 1) + || x == (-2 | 2) + || x == (-2 | 3) + || x == (-1 | -2) + || x == (-1 | -1) + || x == (-1 | 0) + || x == (-1 | 1) + || x == (-1 | 2) + || x == (-1 | 3)) + return 0; + abort (); + } + return 0; +} + +int test900 (int a, int b) +{ + if (a >= -1 && a <= 2 && b >= 3 && b <= 3) + { + int x = a & b; + if (x == (-1 & 3) + || x == (0 & 3) + || x == (1 & 3) + || x == (2 & 3)) + return 0; + abort (); + } + return 0; +} + +int main() +{ + int a, b; + for (a = -4; a < 4; ++a) + for (b = -4; b < 4; ++b) + { + test381 (a, b); + test900 (a, b); + } + + return 0; +} |