re PR tree-optimization/66449 (ICE: in build2_stat, at tree.c:4376 with -O3)

PR tree-optimization/66449
	* tree-ssa-loop-niter.c (loop_exits_before_overflow): Use
	POINTER_PLUS_EXPR for pointers.

	gcc/testsuite
	PR tree-optimization/66449
	* gcc.dg/vect/pr66449.c: New test.

From-SVN: r224769
This commit is contained in:
Bin Cheng 2015-06-23 02:27:49 +00:00 committed by Bin Cheng
parent 350911e651
commit 109bd2e61f
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2015-06-23 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/66449
* tree-ssa-loop-niter.c (loop_exits_before_overflow): Use
POINTER_PLUS_EXPR for pointers.
2015-06-23 Alan Modra <amodra@gmail.com>
* rtlanal.c (commutative_operand_precedence): Correct comments.

View File

@ -1,3 +1,8 @@
2015-06-23 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/66449
* gcc.dg/vect/pr66449.c: New test.
2015-06-22 Pierre-Marie de Rodat <derodat@adacore.com>
* g++.dg/other/dump-ada-spec-5.C: New test.

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-options "-O3" } */
void *fn1(void *p1, void *p2, long p3)
{
long a = (long)p1, b = (long)p2, c = p3;
while (c)
{
int d = ((int *)b)[0];
c--;
((char *)a)[0] = d;
a++;
}
return 0;
}

View File

@ -3888,7 +3888,12 @@ loop_exits_before_overflow (tree base, tree step,
by proving the reverse conditions are false using loop's initial
condition. */
stepped = fold_build2 (PLUS_EXPR, TREE_TYPE (base), base, step);
if (POINTER_TYPE_P (TREE_TYPE (base)))
code = POINTER_PLUS_EXPR;
else
code = PLUS_EXPR;
stepped = fold_build2 (code, TREE_TYPE (base), base, step);
if (operand_equal_p (stepped, civ->base, 0))
{
if (tree_int_cst_sign_bit (step))