This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 36/65] chrec_apply should only apply to the specified variable.


From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>

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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@162244 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog          |    6 ++++++
 gcc/ChangeLog.graphite |    6 ++++++
 gcc/tree-chrec.c       |   45 +++++++++++++++++++++++++++++++--------------
 3 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ec0f773..46b7c59 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
 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.
 	(debug_clast_name_indexes_1): Removed.
 	(debug_clast_name_indexes): Removed.
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 3c7615b..c46bd70 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,11 @@
 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.
 	(debug_clast_name_indexes_1): Removed.
 	(debug_clast_name_indexes): Removed.
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index c92b6b9..92f8de9 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -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))
     {
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]