Patchwork [1/2] Fixup dr_analyze_indices, fix PR50067

login
register
mail settings
Submitter Richard Guenther
Date Aug. 19, 2011, 12:38 p.m.
Message ID <alpine.LNX.2.00.1108191435410.2130@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/110587/
State New
Headers show

Comments

Richard Guenther - Aug. 19, 2011, 12:38 p.m.
This is a first piece of dr_analyze_indices TLC, simplifying
it (no INDIRECT_REFs anymore) and fixing one appearant bug
(but not 50067 yet), that we strip the MEM_REF offset even
if we didn't account for it (if !nest).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-08-19  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/50067
	* tree-data-ref.c (dr_analyze_indices): Simplify, strip MEM_REF
	offset only if we accounted for it.

Patch

Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c	(revision 177894)
+++ gcc/tree-data-ref.c	(working copy)
@@ -863,17 +863,20 @@  dr_analyze_indices (struct data_referenc
     }
 
   if (nest
-      && (INDIRECT_REF_P (aref)
-	  || TREE_CODE (aref) == MEM_REF))
+      && TREE_CODE (aref) == MEM_REF)
     {
       op = TREE_OPERAND (aref, 0);
       access_fn = analyze_scalar_evolution (loop, op);
       access_fn = instantiate_scev (before_loop, loop, access_fn);
       base = initial_condition (access_fn);
       split_constant_offset (base, &base, &off);
-      if (TREE_CODE (aref) == MEM_REF)
-	off = size_binop (PLUS_EXPR, off,
-			  fold_convert (ssizetype, TREE_OPERAND (aref, 1)));
+      if (!integer_zerop (TREE_OPERAND (aref, 1)))
+	{
+	  off = size_binop (PLUS_EXPR, off,
+			    fold_convert (ssizetype, TREE_OPERAND (aref, 1)));
+	  TREE_OPERAND (aref, 1)
+	    = build_int_cst (TREE_TYPE (TREE_OPERAND (aref, 1)), 0);
+	}
       access_fn = chrec_replace_initial_condition (access_fn,
 			fold_convert (TREE_TYPE (base), off));
 
@@ -881,10 +884,6 @@  dr_analyze_indices (struct data_referenc
       VEC_safe_push (tree, heap, access_fns, access_fn);
     }
 
-  if (TREE_CODE (aref) == MEM_REF)
-    TREE_OPERAND (aref, 1)
-      = build_int_cst (TREE_TYPE (TREE_OPERAND (aref, 1)), 0);
-
   if (TREE_CODE (ref) == MEM_REF
       && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR
       && integer_zerop (TREE_OPERAND (ref, 1)))