Index: gimple-fold.c
===================================================================
--- gimple-fold.c	(revision 163859)
+++ gimple-fold.c	(working copy)
@@ -462,14 +474,11 @@ static tree
 maybe_fold_reference (tree expr, bool is_lhs)
 {
   tree *t = &expr;
+  tree result;
 
-  if (TREE_CODE (expr) == ARRAY_REF
-      && !is_lhs)
-    {
-      tree tem = fold_read_from_constant_string (expr);
-      if (tem)
-	return tem;
-    }
+  if (!is_lhs
+      && (result = fold_const_aggregate_ref (expr)))
+    return result;
 
   /* ???  We might want to open-code the relevant remaining cases
      to avoid using the generic fold.  */
Index: tree-ssa-ccp.c
===================================================================
--- tree-ssa-ccp.c	(revision 163859)
+++ tree-ssa-ccp.c	(working copy)
@@ -1325,6 +1325,10 @@ fold_const_aggregate_ref (tree t)
   if (TREE_CODE_CLASS (TREE_CODE (t)) == tcc_declaration)
     return get_symbol_constant_value (t);
 
+  tem = fold_read_from_constant_string (t);
+  if (tem)
+    return tem;
+
   switch (TREE_CODE (t))
     {
     case ARRAY_REF:
