@@ -367,7 +367,7 @@ unswitch_single_loop (struct loop *loop,
fprintf (dump_file, ";; Unswitching loop\n");
/* Unswitch the loop on this condition. */
- nloop = unswitch_loop (loop, bbs[i], cond, cinsn);
+ nloop = unswitch_loop (loop, bbs[i], copy_rtx_if_shared (cond), cinsn);
gcc_assert (nloop);
/* Invoke itself on modified loops. */
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/52092 */
+
+int a, b, c, d, e, f, g;
+
+void
+foo (void)
+{
+ for (;;)
+ {
+ int *h = 0;
+ int i = 3;
+ int **j = &h;
+ if (e)
+ {
+ c = d || a;
+ g = c ? a : b;
+ if ((char) (i * g))
+ {
+ h = &f;
+ *h = 0;
+ }
+ **j = 0;
+ }
+ }
+}