--- gcc/cfgexpand.c.jj	2011-02-21 15:37:42.000000000 +0100
+++ gcc/cfgexpand.c	2011-03-02 11:05:32.000000000 +0100
@@ -2578,11 +2578,25 @@ expand_debug_expr (tree exp)
       }
 
     case MEM_REF:
+      if (!is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
+	{
+	  tree newexp = fold_binary (MEM_REF, TREE_TYPE (exp),
+				     TREE_OPERAND (exp, 0),
+				     TREE_OPERAND (exp, 1));
+	  if (newexp)
+	    exp = newexp;
+	}
+      /* FALLTHROUGH */
     case INDIRECT_REF:
       op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
       if (!op0)
 	return NULL;
 
+      if (POINTER_TYPE_P (TREE_TYPE (exp)))
+	as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
+      else
+	as = ADDR_SPACE_GENERIC;
+
       if (TREE_CODE (exp) == MEM_REF)
 	{
 	  if (GET_CODE (op0) == DEBUG_IMPLICIT_PTR
@@ -2597,12 +2611,10 @@ expand_debug_expr (tree exp)
 	    return NULL;
 
 	  op0 = plus_constant (op0, INTVAL (op1));
-	}
 
-      if (POINTER_TYPE_P (TREE_TYPE (exp)))
-	as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
-      else
-	as = ADDR_SPACE_GENERIC;
+	  if (!is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
+	    exp = TREE_TYPE (exp);
+	}
 
       op0 = convert_debug_memory_address (targetm.addr_space.address_mode (as),
 					  op0, as);
