re PR tree-optimization/53550 (ICE with -O{1,2,3} -fprefetch-loop-arrays in build2_stat, at tree.c:3803)

PR tree-optimization/53550
	* tree-ssa-loop-niter.c (number_of_iterations_cond): If type
	is POINTER_TYPE_P, use sizetype as step type instead of type.

	* gcc.dg/pr53550.c: New test.

From-SVN: r188170
This commit is contained in:
Jakub Jelinek 2012-06-04 11:27:00 +02:00
parent 3156520d5d
commit 67737d058f
4 changed files with 29 additions and 5 deletions

View File

@ -1,5 +1,11 @@
2012-06-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/53550
* tree-ssa-loop-niter.c (number_of_iterations_cond): If type
is POINTER_TYPE_P, use sizetype as step type instead of type.
2012-06-04 Richard Guenther <rguenther@suse.de>
Eric Botcazou <ebotcazou@adacore.com>
Eric Botcazou <ebotcazou@adacore.com>
Backport from mainline
2012-04-03 Eric Botcazou <ebotcazou@adacore.com>

View File

@ -1,5 +1,10 @@
2012-06-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/53550
* gcc.dg/pr53550.c: New test.
2012-06-04 Richard Guenther <rguenther@suse.de>
Eric Botcazou <ebotcazou@adacore.com>
Eric Botcazou <ebotcazou@adacore.com>
Backport from mainline
PR middle-end/52080

View File

@ -0,0 +1,12 @@
/* PR tree-optimization/53550 */
/* { dg-do compile } */
/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */
int *
foo (int *x)
{
int *a = x + 10, *b = x, *c = a;
while (b != c)
*--c = *b++;
return x;
}

View File

@ -1,5 +1,5 @@
/* Functions to determine/estimate number of iterations of a loop.
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of GCC.
@ -1276,13 +1276,14 @@ number_of_iterations_cond (struct loop *loop,
practice, but it is simple enough to manage. */
if (!integer_zerop (iv0->step) && !integer_zerop (iv1->step))
{
tree step_type = POINTER_TYPE_P (type) ? sizetype : type;
if (code != NE_EXPR)
return false;
iv0->step = fold_binary_to_constant (MINUS_EXPR, type,
iv0->step = fold_binary_to_constant (MINUS_EXPR, step_type,
iv0->step, iv1->step);
iv0->no_overflow = false;
iv1->step = build_int_cst (type, 0);
iv1->step = build_int_cst (step_type, 0);
iv1->no_overflow = true;
}