From 5ece98479f869dfda91d31c0907b8e97d996c60b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 4 Jun 2012 11:23:27 +0200 Subject: [PATCH] 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: r188169 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr53550.c | 12 ++++++++++++ gcc/tree-ssa-loop-niter.c | 5 +++-- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr53550.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d79f2a139f4..b94c8beaa67 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-06-04 Jakub Jelinek + + 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 * tree-data-ref.c (have_similar_memory_accesses_1): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 69019bfba5a..75b5be4f4cf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-06-04 Jakub Jelinek + + PR tree-optimization/53550 + * gcc.dg/pr53550.c: New test. + 2012-06-04 Richard Guenther * gcc.dg/tree-ssa/ldist-11.c: Enable -ftree-loop-distribute-patterns. diff --git a/gcc/testsuite/gcc.dg/pr53550.c b/gcc/testsuite/gcc.dg/pr53550.c new file mode 100644 index 00000000000..1008f43a7e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr53550.c @@ -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; +} diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index c7c4a15bef4..501c431d4c8 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1275,13 +1275,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; } -- 2.30.2