2012-06-18  Jiri Hruska  <jirka@fud.cz>

	* gcc/tree-dfa: Fix for incorrect folding of indexed TARGET_MEM_REF
	into constant during dominator optimization, yielding invalid code
	being generated.

--- tree-dfa.c	Sun Apr 29 12:04:39 2012
+++ tree-dfa.c	Mon Jun 18 06:10:41 2012
@@ -891,13 +891,13 @@
 	  if (TREE_CODE (TMR_BASE (exp)) == ADDR_EXPR)
 	    {
 	      /* Via the variable index or index2 we can reach the
-		 whole object.  */
+		 whole object. Force returned max_size to -1. */
 	      if (TMR_INDEX (exp) || TMR_INDEX2 (exp))
 		{
-		  exp = TREE_OPERAND (TMR_BASE (exp), 0);
-		  bit_offset = 0;
-		  maxsize = -1;
-		  goto done;
+		  *poffset = 0;
+		  *psize = bitsize;
+		  *pmax_size = -1;
+		  return TREE_OPERAND (TMR_BASE (exp), 0);
 		}
 	      if (integer_zerop (TMR_OFFSET (exp)))
 		exp = TREE_OPERAND (TMR_BASE (exp), 0);
