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] In Graphite, don't compute the new IV type based on the old_iv type


Hi,

The attached patch is one step forward in eliminating the need
to canonicalize the IVs in loops handled by graphite.  The patch
eliminates one use of the loop->single_iv in the computation of
the type of the new induction variable.

I committed this patch to the graphite branch for a full test.
I will commit this to trunk once that passes.

Sebastian Pop
--
AMD / Open Source Compiler Engineering / GNU Tools
From b1030d21297bb4d019dee3ca606880e9e165105f Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Fri, 11 Jun 2010 13:05:37 -0500
Subject: [PATCH] Don't call pbb_to_depth_to_oldiv from compute_type_for_level.

2010-06-11  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-clast-to-gimple.c (gcc_type_for_interval): Do not pass
	old_type in parameter.
	(gcc_type_for_value): Update call to gcc_type_for_interval.
	(compute_type_for_level_1): Renamed compute_type_for_level.
	Update call to gcc_type_for_interval.
---
 gcc/ChangeLog.graphite         |    8 +++++++
 gcc/graphite-clast-to-gimple.c |   46 +++++++---------------------------------
 2 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 18adc7a..6df816b 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,11 @@
+2010-06-11  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* graphite-clast-to-gimple.c (gcc_type_for_interval): Do not pass
+	old_type in parameter.
+	(gcc_type_for_value): Update call to gcc_type_for_interval.
+	(compute_type_for_level_1): Renamed compute_type_for_level.
+	Update call to gcc_type_for_interval.
+
 2010-06-09  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* tree-scalar-evolution.c (instantiate_scev_name): Do not fail
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index ee00ed3..a363f5d 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -469,11 +469,10 @@ precision_for_interval (mpz_t low, mpz_t up)
   return precision;
 }
 
-/* Return a type that could represent the integer value VAL, or
-   otherwise return NULL_TREE.  */
+/* Return a type that could represent the integer value VAL.  */
 
 static tree
-gcc_type_for_interval (mpz_t low, mpz_t up, tree old_type)
+gcc_type_for_interval (mpz_t low, mpz_t up)
 {
   bool unsigned_p = true;
   int precision, prec_up, prec_int;
@@ -482,14 +481,12 @@ gcc_type_for_interval (mpz_t low, mpz_t up, tree old_type)
 
   gcc_assert (value_le (low, up));
 
-  /* Preserve the signedness of the old IV.  */
-  if ((old_type && !TYPE_UNSIGNED (old_type))
-      || value_neg_p (low))
+  if (value_neg_p (low))
     unsigned_p = false;
 
   prec_up = precision_for_value (up);
   prec_int = precision_for_interval (low, up);
-  precision = prec_up > prec_int ? prec_up : prec_int;
+  precision = MAX (prec_up, prec_int);
 
   if (precision > BITS_PER_WORD)
     {
@@ -516,7 +513,7 @@ gcc_type_for_interval (mpz_t low, mpz_t up, tree old_type)
 static tree
 gcc_type_for_value (mpz_t val)
 {
-  return gcc_type_for_interval (val, val, NULL_TREE);
+  return gcc_type_for_interval (val, val);
 }
 
 /* Return the type for the clast_term T used in STMT.  */
@@ -726,11 +723,10 @@ compute_bounds_for_level (poly_bb_p pbb, int level, mpz_t low, mpz_t up)
 }
 
 /* Compute the type for the induction variable at LEVEL for the
-   statement PBB, based on the transformed schedule of PBB.  OLD_TYPE
-   is the type of the old induction variable for that loop.  */
+   statement PBB, based on the transformed schedule of PBB.  */
 
 static tree
-compute_type_for_level_1 (poly_bb_p pbb, int level, tree old_type)
+compute_type_for_level (poly_bb_p pbb, int level)
 {
   mpz_t low, up;
   tree type;
@@ -739,39 +735,13 @@ compute_type_for_level_1 (poly_bb_p pbb, int level, tree old_type)
   value_init (up);
 
   compute_bounds_for_level (pbb, level, low, up);
-  type = gcc_type_for_interval (low, up, old_type);
+  type = gcc_type_for_interval (low, up);
 
   value_clear (low);
   value_clear (up);
   return type;
 }
 
-/* Compute the type for the induction variable at LEVEL for the
-   statement PBB, based on the transformed schedule of PBB.  */
-
-static tree
-compute_type_for_level (poly_bb_p pbb, int level)
-{
-  tree oldiv = pbb_to_depth_to_oldiv (pbb, level);
-  tree type = TREE_TYPE (oldiv);
-
-  if (type && POINTER_TYPE_P (type))
-    {
-#ifdef ENABLE_CHECKING
-      tree ctype = compute_type_for_level_1 (pbb, level, type);
-
-      /* In the case of a pointer type, check that after the loop
-	 transform, the lower and the upper bounds of the type fit the
-	 oldiv pointer type.  */
-      gcc_assert (TYPE_PRECISION (type) >= TYPE_PRECISION (ctype)
-		  && integer_zerop (lower_bound_in_type (ctype, ctype)));
-#endif
-      return type;
-    }
-
-  return compute_type_for_level_1 (pbb, level, type);
-}
-
 /* Walks a CLAST and returns the first statement in the body of a
    loop.  */
 
-- 
1.7.0.4


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