diff mbox

[4/6] Also handle ARRAY_REFs in instantiate_scev_r.

Message ID 1282347880-797-5-git-send-email-sebpop@gmail.com
State New
Headers show

Commit Message

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

	* tree-scalar-evolution.c (instantiate_array_ref): New.
	(instantiate_scev_r): Also handle ARRAY_REFs.
---
 gcc/ChangeLog.graphite      |    5 +++++
 gcc/tree-scalar-evolution.c |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

Comments

H.J. Lu Oct. 13, 2010, 4:33 a.m. UTC | #1
On Fri, Aug 20, 2010 at 4:44 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> 2010-08-20  Sebastian Pop  <sebastian.pop@amd.com>
>
>        * tree-scalar-evolution.c (instantiate_array_ref): New.
>        (instantiate_scev_r): Also handle ARRAY_REFs.
> ---

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45991
diff mbox

Patch

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index c8d810c..f1879f2 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,10 @@ 
 2010-08-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* tree-scalar-evolution.c (instantiate_array_ref): New.
+	(instantiate_scev_r): Also handle ARRAY_REFs.
+
+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
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 24e19e0..671494c 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -2319,6 +2319,41 @@  instantiate_scev_binary (basic_block instantiate_below,
 /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
    and EVOLUTION_LOOP, that were left under a symbolic form.
 
+   "CHREC" is an array reference to be instantiated.
+
+   CACHE is the cache of already instantiated values.
+
+   FOLD_CONVERSIONS should be set to true when the conversions that
+   may wrap in signed/pointer type are folded, as long as the value of
+   the chrec is preserved.
+
+   SIZE_EXPR is used for computing the size of the expression to be
+   instantiated, and to stop if it exceeds some limit.  */
+
+static tree
+instantiate_array_ref (basic_block instantiate_below,
+		       struct loop *evolution_loop, tree chrec,
+		       bool fold_conversions, htab_t cache, int size_expr)
+{
+  tree res;
+  tree index = TREE_OPERAND (chrec, 1);
+  tree op1 = instantiate_scev_r (instantiate_below, evolution_loop, index,
+				 fold_conversions, cache, size_expr);
+
+  if (op1 == chrec_dont_know)
+    return chrec_dont_know;
+
+  if (chrec && op1 == index)
+    return chrec;
+
+  res = unshare_expr (chrec);
+  TREE_OPERAND (res, 1) = op1;
+  return res;
+}
+
+/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
+   and EVOLUTION_LOOP, that were left under a symbolic form.
+
    "CHREC" that stands for a convert expression "(TYPE) OP" is to be
    instantiated.
 
@@ -2595,6 +2630,10 @@  instantiate_scev_r (basic_block instantiate_below,
     case SCEV_KNOWN:
       return chrec_known;
 
+    case ARRAY_REF:
+      return instantiate_array_ref (instantiate_below, evolution_loop, chrec,
+				    fold_conversions, cache, size_expr);
+
     default:
       break;
     }