Commit 90c6f26c by Richard Biener Committed by Richard Biener

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
parent 18f60146
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.
......
......@@ -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)
......
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.
......
/* { 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" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment