re PR middle-end/46885 (ICE: in gsi_insert_seq_nodes_after, at gimple-iterator.c...
authorJakub Jelinek <jakub@redhat.com>
Tue, 14 Dec 2010 14:11:16 +0000 (15:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 14 Dec 2010 14:11:16 +0000 (15:11 +0100)
PR debug/46885
* tree-ssa-loop-manip.c (canonicalize_loop_ivs): Use gsi_last_bb
instead of gsi_last_nondebug_bb if bump_in_latch.

* gcc.dg/autopar/pr46885.c: New test.

From-SVN: r167801

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/autopar/pr46885.c [new file with mode: 0644]
gcc/tree-ssa-loop-manip.c

index b4efa6fe7ac5b37896dd435b3bdabdfb4bb6be68..9416805cc3da1bc1a773425f73caff5e4f0fd228 100644 (file)
@@ -1,5 +1,9 @@
 2010-12-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/46885
+       * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Use gsi_last_bb
+       instead of gsi_last_nondebug_bb if bump_in_latch.
+
        PR tree-optimization/46909
        * gimple-fold.c (and_var_with_comparison_1): Save partial
        result even in the is_and case, if both partial results
index 0d20e5127f9590466002311c1f4d9f9986439788..1057858549d4cd2de7e08aaa3c50b6d74c5b2c4a 100644 (file)
@@ -1,5 +1,8 @@
 2010-12-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/46885
+       * gcc.dg/autopar/pr46885.c: New test.
+
        PR tree-optimization/46909
        * gcc.c-torture/execute/pr46909-1.c: New test.
        * gcc.c-torture/execute/pr46909-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/autopar/pr46885.c b/gcc/testsuite/gcc.dg/autopar/pr46885.c
new file mode 100644 (file)
index 0000000..9560c92
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR debug/46885 */
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-parallelize-loops=4 -fcompare-debug -fno-tree-dominator-opts -funswitch-loops" } */
+
+static inline void
+bar (int i)
+{
+  (void) i;
+}
+
+int
+foo (int *begin, int *end)
+{
+  int s = 0;
+  int *i;
+  for (i = begin; i != end; ++i)
+    {
+      bar (0);
+      if (begin)
+       return s;
+    }
+  return 0;
+}
index 87b2c0d095d9b05aca334a9d92024a0e077169e0..8176ed8d04cab3bd8ebe21db79191e3e13390233 100644 (file)
@@ -1221,7 +1221,10 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
        gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
     }
 
-  gsi = gsi_last_nondebug_bb (bump_in_latch ? loop->latch : loop->header);
+  if (bump_in_latch)
+    gsi = gsi_last_bb (loop->latch);
+  else
+    gsi = gsi_last_nondebug_bb (loop->header);
   create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
             loop, &gsi, bump_in_latch, &var_before, NULL);