public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][mem-ref2] Fixup tree-affine.c
@ 2010-06-25 11:43 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2010-06-25 11:43 UTC (permalink / raw)
  To: gcc-patches


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;
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-25  9:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-25 11:43 [PATCH][mem-ref2] Fixup tree-affine.c Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).