diff options
author | Richard Biener <rguenther@suse.de> | 2016-02-02 15:19:32 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-02-02 15:19:32 +0000 |
commit | 90c6f26c8bc51f00827fcaa4b768d97ebf720ef5 (patch) | |
tree | 0fb720ef1b494a46acb199b90cbc2d028079a1e1 /gcc | |
parent | 18f60146494a8c90d5dfc1f640b48f2f34a1588c (diff) | |
download | gcc-90c6f26c8bc51f00827fcaa4b768d97ebf720ef5.zip gcc-90c6f26c8bc51f00827fcaa4b768d97ebf720ef5.tar.gz gcc-90c6f26c8bc51f00827fcaa4b768d97ebf720ef5.tar.bz2 |
re PR tree-optimization/69595 (Bogus -Warray-bound warning due to missed optimization)
2016-02-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/69595
* match.pd: Add range test simplifications to true/false.
* gcc.dg/Warray-bounds-17.c: New testcase.
From-SVN: r233076
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/match.pd | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Warray-bounds-17.c | 13 |
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a2cec8..3b548f5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-02-02 Richard Biener <rguenther@suse.de> + + PR tree-optimization/69595 + * match.pd: Add range test simplifications to true/false. + 2016-02-02 Thomas Schwinge <thomas@codesourcery.com> * omp-builtins.def (BUILT_IN_GOACC_HOST_DATA): Remove. diff --git a/gcc/match.pd b/gcc/match.pd index 491f769..6c8ebd5 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2094,6 +2094,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1)) @2) +/* Simple range test simplifications. */ +/* A < B || A >= B -> true. */ +(for test1 (lt le ne) + test2 (ge gt eq) + (simplify + (bit_ior:c (test1 @0 @1) (test2 @0 @1)) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) + || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0))) + { constant_boolean_node (true, type); }))) +/* A < B && A >= B -> false. */ +(for test1 (lt lt lt le ne eq) + test2 (ge gt eq gt eq gt) + (simplify + (bit_and:c (test1 @0 @1) (test2 @0 @1)) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) + || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0))) + { constant_boolean_node (false, type); }))) + /* -A CMP -B -> B CMP A. */ (for cmp (tcc_comparison) scmp (swapped_tcc_comparison) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9d89eee..9ed6c54 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2016-02-02 Richard Biener <rguenther@suse.de> + PR tree-optimization/69595 + * gcc.dg/Warray-bounds-17.c: New testcase. + +2016-02-02 Richard Biener <rguenther@suse.de> + PR tree-optimization/69606 * gcc.dg/torture/pr69606.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-17.c b/gcc/testsuite/gcc.dg/Warray-bounds-17.c new file mode 100644 index 0000000..e790037 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-17.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +char *y; +void foo (int sysnum) +{ + static char *x[] = {}; + int nsyscalls = sizeof x / sizeof x[0]; + if (sysnum < 0 || sysnum >= nsyscalls) + return; + else + y = x[sysnum]; /* { dg-bogus "above array bounds" } */ +} |