diff mbox

Fix MEM_REF offset calculation in dr_analyze_innermost

Message ID Pine.LNX.4.64.1205311303280.5860@jbgna.fhfr.qr
State New
Headers show

Commit Message

Richard Biener May 31, 2012, 11:04 a.m. UTC
Pointed out by people working on targets with ptr-size != sizetype size.

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

Richard.

2012-05-31  Richard Guenther  <rguenther@suse.de>

	* tree-data-ref.c (dr_analyze_innermost): Properly convert
	the MEM_REF offset to sizetype.
diff mbox

Patch

Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c	(revision 188055)
+++ gcc/tree-data-ref.c	(working copy)
@@ -755,13 +755,12 @@  dr_analyze_innermost (struct data_refere
     {
       if (!integer_zerop (TREE_OPERAND (base, 1)))
 	{
+	  double_int moff = mem_ref_offset (base);
+	  tree mofft = double_int_to_tree (sizetype, moff);
 	  if (!poffset)
-	    {
-	      double_int moff = mem_ref_offset (base);
-	      poffset = double_int_to_tree (sizetype, moff);
-	    }
+	    poffset = mofft;
 	  else
-	    poffset = size_binop (PLUS_EXPR, poffset, TREE_OPERAND (base, 1));
+	    poffset = size_binop (PLUS_EXPR, poffset, mofft);
 	}
       base = TREE_OPERAND (base, 0);
     }