@@ -1538,7 +1538,10 @@ loop_version (struct loop *loop,
/* Duplicate loop. */
if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1,
NULL, NULL, NULL, 0))
- return NULL;
+ {
+ entry->flags |= irred_flag;
+ return NULL;
+ }
/* After duplication entry edge now points to new loop head block.
Note down new head as second_head. */
@@ -0,0 +1,16 @@
+/* PR tree-optimization/46107 */
+
+int foo (void) __attribute__ ((noreturn));
+
+void
+bar (int x, int *y, int z)
+{
+ static void *j[] = { &&l1, &&l2 };
+l1:
+ if (*y)
+ goto *j[z];
+ foo ();
+l2:
+ *y ^= (x & 1) ? -1 : 0;
+ goto *j[x];
+}