diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 3aaa49069997c1d771a0ced82c9be1f4bf23fed1..76a1393ab23e7982ab9a51c4de48f3e4b32da881 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -5424,6 +5424,11 @@ lra_constraints (bool first_p)
 					   loc_equivalence_callback, curr_insn);
 	      if (old != *curr_id->operand_loc[0])
 		{
+		  /* If we substitute pseudo by shared equivalence, we can fail
+		     to update LRA reg info and this can result in many
+		     unexpected consequences.  So keep rtl unshared:  */
+		  *curr_id->operand_loc[0]
+		    = copy_rtx (*curr_id->operand_loc[0]);
 		  lra_update_insn_regno_info (curr_insn);
 		  changed_p = true;
 		}
diff --git a/gcc/lra.cc b/gcc/lra.cc
index 563aff10b9658b5a26dfeaad741633aaf7df009c..361f84fdacb65cef8c1bf4c1bed2aad1e559da65 100644
--- a/gcc/lra.cc
+++ b/gcc/lra.cc
@@ -2579,9 +2579,8 @@ lra (FILE *f)
   if (inserted_p)
     commit_edge_insertions ();
 
-  /* Replacing pseudos with their memory equivalents might have
-     created shared rtx.  Subsequent passes would get confused
-     by this, so unshare everything here.  */
+  /* Subsequent passes expect that rtl is unshared, so unshare everything
+     here.  */
   unshare_all_rtl_again (get_insns ());
 
   if (flag_checking)
diff --git a/gcc/testsuite/g++.target/i386/pr111497.C b/gcc/testsuite/g++.target/i386/pr111497.C
new file mode 100644
index 0000000000000000000000000000000000000000..a645bb95907ee34a2145a6cf01f0c26630a37155
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr111497.C
@@ -0,0 +1,22 @@
+// { dg-do compile { target ia32 } }
+// { dg-options "-march=i686 -mtune=generic -fPIC -O2 -g" }
+
+class A;
+struct B { const char *b1; int b2; };
+struct C : B { C (const char *x, int y) { b1 = x; b2 = y; } };
+struct D : C { D (B x) : C (x.b1, x.b2) {} };
+struct E { E (A *); };
+struct F : E { D f1, f2, f3, f4, f5, f6; F (A *, const B &, const B &, const B &); };
+struct G : F { G (A *, const B &, const B &, const B &); };
+struct H { int h; };
+struct I { H i; };
+struct J { I *j; };
+struct A : J {};
+inline F::F (A *x, const B &y, const B &z, const B &w)
+  : E(x), f1(y), f2(z), f3(w), f4(y), f5(z), f6(w) {}
+G::G (A *x, const B &y, const B &z, const B &w) : F(x, y, z, w)
+{
+  H *h = &x->j->i;
+  if (h)
+    h->h++;
+}