diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9536e0a73d8..7f2a5ae51e7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-12-18 Jakub Jelinek + + PR tree-optimization/46985 + * tree-scalar-evolution.c (instantiate_scev_r): If chrec is NULL, + return it immediately. + 2010-12-18 John David Anglin PR target/46915 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 64b9ffece4e..711f3437e74 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-12-18 Jakub Jelinek + + PR tree-optimization/46985 + * gfortran.dg/pr46985.f90: New test. + 2010-12-18 Eric Botcazou PR tree-optimization/46232 diff --git a/gcc/testsuite/gfortran.dg/pr46985.f90 b/gcc/testsuite/gfortran.dg/pr46985.f90 new file mode 100644 index 00000000000..141641d29e9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr46985.f90 @@ -0,0 +1,17 @@ +! PR tree-optimization/46985 +! { dg-do compile } +! { dg-options "-O -ftree-pre -ftree-vrp -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-fre" } + + type :: t + integer :: i + end type t + type(t), target :: tar(2) = (/t(2), t(4)/) + integer, pointer :: ptr(:) + ptr => tar%i + call foo (ptr) +contains + subroutine foo (arg) + integer :: arg(:) + arg = arg - 1 + end subroutine +end diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 4a4bda9d925..24be2e8c26f 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -2616,7 +2616,8 @@ instantiate_scev_r (basic_block instantiate_below, if (size_expr++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE)) return chrec_dont_know; - if (automatically_generated_chrec_p (chrec) + if (chrec == NULL_TREE + || automatically_generated_chrec_p (chrec) || is_gimple_min_invariant (chrec)) return chrec;