]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
chrec_apply should only apply to the specified variable.
authorSebastian Pop <sebastian.pop@amd.com>
Wed, 11 Aug 2010 20:27:27 +0000 (20:27 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Wed, 11 Aug 2010 20:27:27 +0000 (20:27 +0000)
2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>

* tree-chrec.c (chrec_apply): Should only apply to the specified
variable.  Also handle multivariate chains of recurrences that
satisfy evolution_function_is_affine_p.  Also handle CASE_CONVERT.

From-SVN: r163140

gcc/ChangeLog
gcc/ChangeLog.graphite
gcc/tree-chrec.c

index f333453ff5a1bc493fbbe717be7639fcb4cc5b4c..3a903947706f866c6169c486f91e791e1d7862b6 100644 (file)
@@ -1,3 +1,9 @@
+2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * tree-chrec.c (chrec_apply): Should only apply to the specified
+       variable.  Also handle multivariate chains of recurrences that
+       satisfy evolution_function_is_affine_p.  Also handle CASE_CONVERT.
+
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
 
        * graphite-clast-to-gimple.c (debug_clast_name_index): Removed.
index 3c7615b39817ad39dbd97ec572020101f7a4d0fc..c46bd703214ee9586ac507138eb826eaae3c5259 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * tree-chrec.c (chrec_apply): Should only apply to the specified
+       variable.  Also handle multivariate chains of recurrences that
+       satisfy evolution_function_is_affine_p.  Also handle CASE_CONVERT.
+
 2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>
 
        * graphite-clast-to-gimple.c (debug_clast_name_index): Removed.
index c92b6b9837c7a14a8b50298b3284def2ce3753c7..92f8de9f0eb618612e56a5d802f9867cf70050ac 100644 (file)
@@ -599,23 +599,40 @@ chrec_apply (unsigned var,
   if (TREE_CODE (x) == INTEGER_CST && SCALAR_FLOAT_TYPE_P (type))
     x = build_real_from_int_cst (type, x);
 
-  if (evolution_function_is_affine_p (chrec))
+  switch (TREE_CODE (chrec))
     {
-      /* "{a, +, b} (x)"  ->  "a + b*x".  */
-      x = chrec_convert_rhs (type, x, NULL);
-      res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x);
-      res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
-    }
+    case POLYNOMIAL_CHREC:
+      if (evolution_function_is_affine_p (chrec))
+       {
+         if (CHREC_VARIABLE (chrec) != var)
+           return build_polynomial_chrec
+             (CHREC_VARIABLE (chrec),
+              chrec_apply (var, CHREC_LEFT (chrec), x),
+              chrec_apply (var, CHREC_RIGHT (chrec), x));
+
+         /* "{a, +, b} (x)"  ->  "a + b*x".  */
+         x = chrec_convert_rhs (type, x, NULL);
+         res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x);
+         res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
+       }
+      else if (TREE_CODE (x) == INTEGER_CST
+              && tree_int_cst_sgn (x) == 1)
+       /* testsuite/.../ssa-chrec-38.c.  */
+       res = chrec_evaluate (var, chrec, x, 0);
+      else
+       res = chrec_dont_know;
+      break;
 
-  else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
-    res = chrec;
+    CASE_CONVERT:
+      res = chrec_convert (TREE_TYPE (chrec),
+                          chrec_apply (var, TREE_OPERAND (chrec, 0), x),
+                          NULL);
+      break;
 
-  else if (TREE_CODE (x) == INTEGER_CST
-          && tree_int_cst_sgn (x) == 1)
-    /* testsuite/.../ssa-chrec-38.c.  */
-    res = chrec_evaluate (var, chrec, x, 0);
-  else
-    res = chrec_dont_know;
+    default:
+      res = chrec;
+      break;
+    }
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {