[PATCH][mem-ref2] Fixup tree-affine.c

Richard Guenther rguenther@suse.de
Fri Jun 25 11:43:00 GMT 2010


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2010-06-25  Richard Guenther  <rguenther@suse.de>

	* tree-affine.c (tree_to_aff_combination): Handle MEM_REF.

Index: gcc/tree-affine.c
===================================================================
--- gcc/tree-affine.c	(revision 161366)
+++ gcc/tree-affine.c	(working copy)
@@ -309,6 +309,15 @@ tree_to_aff_combination (tree expr, tree
       return;
 
     case ADDR_EXPR:
+      /* Handle &MEM[ptr + CST] which is equivalent to POINTER_PLUS_EXPR.  */
+      if (TREE_CODE (TREE_OPERAND (expr, 0)) == MEM_REF)
+	{
+	  expr = TREE_OPERAND (expr, 0);
+	  tree_to_aff_combination (TREE_OPERAND (expr, 0), type, comb);
+	  tree_to_aff_combination (TREE_OPERAND (expr, 1), sizetype, &tmp);
+	  aff_combination_add (comb, &tmp);
+	  return;
+	}
       core = get_inner_reference (TREE_OPERAND (expr, 0), &bitsize, &bitpos,
 				  &toffset, &mode, &unsignedp, &volatilep,
 				  false);
@@ -331,6 +340,25 @@ tree_to_aff_combination (tree expr, tree
 	}
       return;
 
+    case MEM_REF:
+      if (TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR)
+	tree_to_aff_combination (TREE_OPERAND (TREE_OPERAND (expr, 0), 0),
+				 type, comb);
+      else if (integer_zerop (TREE_OPERAND (expr, 1)))
+	{
+	  aff_combination_elt (comb, type, expr);
+	  return;
+	}
+      else
+	aff_combination_elt (comb, type,
+			     build2 (MEM_REF, TREE_TYPE (expr),
+				     TREE_OPERAND (expr, 0),
+				     build_int_cst
+				      (TREE_TYPE (TREE_OPERAND (expr, 1)), 0)));
+      tree_to_aff_combination (TREE_OPERAND (expr, 1), sizetype, &tmp);
+      aff_combination_add (comb, &tmp);
+      return;
+
     default:
       break;
     }



More information about the Gcc-patches mailing list