re PR tree-optimization/82449 (code-gen error in get_rename_from_scev)
authorRichard Biener <rguenther@suse.de>
Mon, 9 Oct 2017 13:50:10 +0000 (13:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 9 Oct 2017 13:50:10 +0000 (13:50 +0000)
2017-10-09  Richard Biener  <rguenther@suse.de>

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

gcc/ChangeLog
gcc/sese.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/graphite/pr82449.f [new file with mode: 0644]
gcc/tree-chrec.c
gcc/tree-chrec.h

index bfcd8541a6d6077709db682d9dd474991c8b7082..44ca159117a1c402ef96468f96fbdb11229dc36a 100644 (file)
@@ -1,3 +1,12 @@
+2017-10-09  Richard Biener  <rguenther@suse.de>
+
+       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  <krebbel@linux.vnet.ibm.com>
 
        * config/s390/s390-builtins.def (vec_nabs, vec_vfi): Fix builtin
index b3bf6114fc78b8b3cb0f7f7891f89e32f3344e00..d6702ada5f4ac2f1a2294bfe9df7489489623f53 100644 (file)
@@ -444,14 +444,13 @@ scev_analyzable_p (tree def, sese_l &region)
   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
index ae952c9cfb02f33db41a9f554a429e39120fe3ba..5768f4260eaf8f59c6fddb8faf4518b23691c073 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82449
+       * gfortran.dg/graphite/pr82449.f: New testcase.
+
 2017-10-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        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 (file)
index 0000000..974ea20
--- /dev/null
@@ -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
index 66d3a7bd370dfc37afeb332843cba03ab3fc1960..3867072566e84e1cd0f644fae7f00cae35d826fd 100644 (file)
@@ -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;
index e980ec174527773d78aede99aa08831b27251f0c..4a8a3734d7952534192217c21b34d50340e8c53c 100644 (file)
@@ -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.  */