gcc/
2015-12-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
	PR tree-optimization/68906
	* tree-ssa-loop-unswitch.c (tree_unswitch_outer_loop): Add check
	that an exit block belongs to LOOP.
gcc/testsuite/
2015-12-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
	PR tree-optimization/68906
	* gcc.dg/torture/pr68906.c: New test.
From-SVN: r231812
+2015-12-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
+       PR tree-optimization/68906
+       * tree-ssa-loop-unswitch.c (tree_unswitch_outer_loop): Add check
+       that an exit block belongs to LOOP.
+
 2015-12-18  Ilya Enkovich  <enkovich.gnu@gmail.com>
 
        PR tree-optimization/68956
 
+2015-12-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
+
+       PR tree-optimization/68906
+       * gcc.dg/torture/pr68906.c: New test.
+
 2015-12-18  Ilya Enkovich  <enkovich.gnu@gmail.com>
 
        PR tree-optimization/68956
 
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int a;
+volatile int b;
+short c, d;
+int
+fn1 ()
+{
+  int e;
+  for (;;)
+    {
+      a = 3;
+      if (c)
+       continue;
+      e = 0;
+      for (; e > -30; e--)
+       if (b)
+         {
+           int f = e;
+           return d;
+         }
+    }
+}
 
   gcc_assert (loop->inner);
   if (loop->inner->next)
     return false;
-  /* Accept loops with single exit only.  */
+  /* Accept loops with single exit only which is not from inner loop.  */
   exit = single_exit (loop);
-  if (!exit)
+  if (!exit || exit->src->loop_father != loop)
     return false;
   /* Check that phi argument of exit edge is not defined inside loop.  */
   if (!check_exit_phi (loop))