re PR tree-optimization/46107 (-ftree-loop-distribute-patterns caused verify_loop_str...
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Nov 2010 09:49:16 +0000 (10:49 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Nov 2010 09:49:16 +0000 (10:49 +0100)
PR tree-optimization/46107
* cfgloopmanip.c (loop_version): Set irred_flag back into entry->flags
if cfg_hook_duplicate_loop_to_header_edge failed.

* gcc.c-torture/compile/pr46107.c: New test.

From-SVN: r166234

gcc/ChangeLog
gcc/cfgloopmanip.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr46107.c [new file with mode: 0644]

index 154ad56f1db9fdbdee6acab165acf0039ae6eafc..b092477b9c85d96dee3bb0195232031a9d91e0a1 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/46107
+       * cfgloopmanip.c (loop_version): Set irred_flag back into entry->flags
+       if cfg_hook_duplicate_loop_to_header_edge failed.
+
 2010-11-03  Ian Lance Taylor  <iant@google.com>
 
        PR lto/46273
index 4363cc51f64062d7bcd3fb52424f313e8975a228..aa9ab66454e2f5e5e2737ec0f59b7eaf72bc9557 100644 (file)
@@ -1,6 +1,6 @@
 /* Loop manipulation code for GNU compiler.
-   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software
-   Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -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.  */
index bb14d86f39694bfedae5c34c98296a44e795dbd8..7af642f493233b51a740ce525e4047d178d6734d 100644 (file)
@@ -1,5 +1,8 @@
 2010-11-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/46107
+       * gcc.c-torture/compile/pr46107.c: New test.
+
        PR debug/46252
        * gcc.dg/pr46252.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr46107.c b/gcc/testsuite/gcc.c-torture/compile/pr46107.c
new file mode 100644 (file)
index 0000000..41582b8
--- /dev/null
@@ -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];
+}