Patchwork [3/6] Fix chrec_contains_symbols_defined_in_loop.

login
register
mail settings
Submitter Sebastian Pop
Date Aug. 20, 2010, 11:44 p.m.
Message ID <1282347880-797-4-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/62334/
State New
Headers show

Comments

Sebastian Pop - Aug. 20, 2010, 11:44 p.m.
2010-08-20  Sebastian Pop  <sebastian.pop@amd.com>

	* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop):
	Do not check for VAR_DECL, PARM_DECL, FUNCTION_DECL, LABEL_DECL,
	RESULT_DECL, and FIELD_DECL.  Return false for an
	SSA_NAME_IS_DEFAULT_DEF.
	(compute_scalar_evolution_in_loop): Do not further analyze the
	scalar evolution when no_evolution_in_loop_p returns true.
---
 gcc/ChangeLog.graphite      |    9 +++++++++
 gcc/tree-scalar-evolution.c |   25 ++++++++++++++-----------
 2 files changed, 23 insertions(+), 11 deletions(-)

Patch

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 16b5dfa..c8d810c 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,14 @@ 
 2010-08-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop):
+	Do not check for VAR_DECL, PARM_DECL, FUNCTION_DECL, LABEL_DECL,
+	RESULT_DECL, and FIELD_DECL.  Return false for an
+	SSA_NAME_IS_DEFAULT_DEF.
+	(compute_scalar_evolution_in_loop): Do not further analyze the
+	scalar evolution when no_evolution_in_loop_p returns true.
+
+2010-08-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* tree-chrec.h (evolution_function_is_affine_p): Do not check
 	whether CHREC_LEFT is invariant.  A function is affine when
 	CHREC_RIGHT is invariant.
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 5b6ce7b..24e19e0 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -385,19 +385,17 @@  chrec_contains_symbols_defined_in_loop (const_tree chrec, unsigned loop_nb)
   if (is_gimple_min_invariant (chrec))
     return false;
 
-  if (TREE_CODE (chrec) == VAR_DECL
-      || TREE_CODE (chrec) == PARM_DECL
-      || TREE_CODE (chrec) == FUNCTION_DECL
-      || TREE_CODE (chrec) == LABEL_DECL
-      || TREE_CODE (chrec) == RESULT_DECL
-      || TREE_CODE (chrec) == FIELD_DECL)
-    return true;
-
   if (TREE_CODE (chrec) == SSA_NAME)
     {
-      gimple def = SSA_NAME_DEF_STMT (chrec);
-      struct loop *def_loop = loop_containing_stmt (def);
-      struct loop *loop = get_loop (loop_nb);
+      gimple def;
+      loop_p def_loop, loop;
+
+      if (SSA_NAME_IS_DEFAULT_DEF (chrec))
+	return false;
+
+      def = SSA_NAME_DEF_STMT (chrec);
+      def_loop = loop_containing_stmt (def);
+      loop = get_loop (loop_nb);
 
       if (def_loop == NULL)
 	return false;
@@ -1816,13 +1814,18 @@  compute_scalar_evolution_in_loop (struct loop *wrto_loop,
 				  struct loop *def_loop,
 				  tree ev)
 {
+  bool val;
   tree res;
+
   if (def_loop == wrto_loop)
     return ev;
 
   def_loop = superloop_at_depth (def_loop, loop_depth (wrto_loop) + 1);
   res = compute_overall_effect_of_inner_loop (def_loop, ev);
 
+  if (no_evolution_in_loop_p (res, wrto_loop->num, &val) && val)
+    return res;
+
   return analyze_scalar_evolution_1 (wrto_loop, res, chrec_not_analyzed_yet);
 }