diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index d6a53f801f0..54c4818998d 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -3646,7 +3646,7 @@ get_constraint_for_1 (tree t, vec<ce_s> *results, bool address_p,
       }
     case tcc_reference:
       {
-	if (TREE_THIS_VOLATILE (t))
+	if (!lhs_p && TREE_THIS_VOLATILE (t))
 	  /* Fall back to anything.  */
 	  break;
 
@@ -3751,7 +3751,7 @@ get_constraint_for_1 (tree t, vec<ce_s> *results, bool address_p,
       }
     case tcc_declaration:
       {
-	if (VAR_P (t) && TREE_THIS_VOLATILE (t))
+	if (!lhs_p && VAR_P (t) && TREE_THIS_VOLATILE (t))
 	  /* Fall back to anything.  */
 	  break;
 	get_constraint_for_ssa_var (t, results, address_p);
