From: Richard Biener Date: Mon, 9 Oct 2017 13:50:10 +0000 (+0000) Subject: re PR tree-optimization/82449 (code-gen error in get_rename_from_scev) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7668b0a65616dec614379a396186f3a03e329965;p=gcc.git re PR tree-optimization/82449 (code-gen error in get_rename_from_scev) 2017-10-09 Richard Biener PR tree-optimization/82449 * sese.c (scev_analyzable_p): Check whether the SCEV is linear. * tree-chrec.h (evolution_function_is_constant_p): Adjust to allow constant addresses. * tree-chrec.c (scev_is_linear_expression): Constant evolutions are linear. * gfortran.dg/graphite/pr82449.f: New testcase. From-SVN: r253546 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bfcd8541a6d..44ca159117a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-10-09 Richard Biener + + PR tree-optimization/82449 + * sese.c (scev_analyzable_p): Check whether the SCEV is linear. + * tree-chrec.h (evolution_function_is_constant_p): Adjust to + allow constant addresses. + * tree-chrec.c (scev_is_linear_expression): Constant evolutions + are linear. + 2017-10-09 Andreas Krebbel * config/s390/s390-builtins.def (vec_nabs, vec_vfi): Fix builtin diff --git a/gcc/sese.c b/gcc/sese.c index b3bf6114fc7..d6702ada5f4 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -444,14 +444,13 @@ scev_analyzable_p (tree def, sese_l ®ion) loop = loop_containing_stmt (SSA_NAME_DEF_STMT (def)); scev = scalar_evolution_in_region (region, loop, def); - return !chrec_contains_undetermined (scev) - && (TREE_CODE (scev) != SSA_NAME - || !defined_in_sese_p (scev, region)) - && (tree_does_not_contain_chrecs (scev) - || evolution_function_is_affine_p (scev)) - && (! loop - || ! loop_in_sese_p (loop, region) - || ! chrec_contains_symbols_defined_in_loop (scev, loop->num)); + return (!chrec_contains_undetermined (scev) + && (TREE_CODE (scev) != SSA_NAME + || !defined_in_sese_p (scev, region)) + && scev_is_linear_expression (scev) + && (! loop + || ! loop_in_sese_p (loop, region) + || ! chrec_contains_symbols_defined_in_loop (scev, loop->num))); } /* Returns the scalar evolution of T in REGION. Every variable that diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ae952c9cfb0..5768f4260ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-09 Richard Biener + + PR tree-optimization/82449 + * gfortran.dg/graphite/pr82449.f: New testcase. + 2017-10-09 Andreas Krebbel PR target/82463 diff --git a/gcc/testsuite/gfortran.dg/graphite/pr82449.f b/gcc/testsuite/gfortran.dg/graphite/pr82449.f new file mode 100644 index 00000000000..974ea206d41 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/pr82449.f @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-O2 -floop-nest-optimize" } + + SUBROUTINE JDFIDX(MKL,KGSH) + DIMENSION MKL(6,6) + NKL=0 + 400 DO 40 KG = 1,KGSH + DO 40 LG = 1,KG + NKL = NKL + 1 + 40 MKL(LG,KG) = NKL + END diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 66d3a7bd370..3867072566e 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -1610,6 +1610,9 @@ operator_is_linear (tree scev) bool scev_is_linear_expression (tree scev) { + if (evolution_function_is_constant_p (scev)) + return true; + if (scev == NULL || !operator_is_linear (scev)) return false; diff --git a/gcc/tree-chrec.h b/gcc/tree-chrec.h index e980ec17452..4a8a3734d79 100644 --- a/gcc/tree-chrec.h +++ b/gcc/tree-chrec.h @@ -169,15 +169,9 @@ evolution_function_is_constant_p (const_tree chrec) if (chrec == NULL_TREE) return false; - switch (TREE_CODE (chrec)) - { - case INTEGER_CST: - case REAL_CST: - return true; - - default: - return false; - } + if (CONSTANT_CLASS_P (chrec)) + return true; + return is_gimple_min_invariant (chrec); } /* Determine whether CHREC is an affine evolution function in LOOPNUM. */