]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/29924 (pr24626-4.c fails on powerpc-aix and others)
authorZdenek Dvorak <dvorakz@suse.cz>
Wed, 22 Nov 2006 00:12:52 +0000 (01:12 +0100)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Wed, 22 Nov 2006 00:12:52 +0000 (00:12 +0000)
PR rtl-optimization/29924
* loop-unroll.c (split_edge_and_insert): Handle the case insns is NULL.
(unroll_loop_runtime_iterations): Assert that the argument passed to
split_edge_and_insert is not NULL.
* loop-doloop.c (add_test): Ditto.

From-SVN: r119078

gcc/ChangeLog
gcc/loop-doloop.c
gcc/loop-unroll.c

index 1ed3890c8e4c4934d85d899c8236b74b638f06b3..8666acc058ccd7d16ca8287fdb3a80189e021df5 100644 (file)
@@ -1,3 +1,11 @@
+2006-11-22  Zdenek Dvorak <dvorakz@suse.cz>
+
+       PR rtl-optimization/29924
+       * loop-unroll.c (split_edge_and_insert): Handle the case insns is NULL.
+       (unroll_loop_runtime_iterations): Assert that the argument passed to
+       split_edge_and_insert is not NULL.
+       * loop-doloop.c (add_test): Ditto.
+
 2006-11-22  Zdenek Dvorak <dvorakz@suse.cz>
 
        * tree-loop-linear.c (linear_transform_loops): Use single_exit accessor
index afe65cb7d288cb65fc13c6caa6c7fcaffbdd1593..004dcfe72f8f7a08a5d49029cb12b55cfa2f5910 100644 (file)
@@ -248,7 +248,7 @@ add_test (rtx cond, edge *e, basic_block dest)
   do_compare_rtx_and_jump (op0, op1, code, 0, mode, NULL_RTX, NULL_RTX, label);
 
   jump = get_last_insn ();
-  if (!JUMP_P (jump))
+  if (!jump || !JUMP_P (jump))
     {
       /* The condition is always false and the jump was optimized out.  */
       end_sequence ();
@@ -257,6 +257,10 @@ add_test (rtx cond, edge *e, basic_block dest)
 
   seq = get_insns ();
   end_sequence ();
+
+  /* There always is at least the jump insn in the sequence.  */
+  gcc_assert (seq != NULL_RTX);
+
   bb = split_edge_and_insert (*e, seq);
   *e = single_succ_edge (bb);
 
index 7d230fb6f3afa41d3b7e1e51431d024835b2cd93..2f6f3ba2ad9862569ef000c7115061de48834862 100644 (file)
@@ -899,13 +899,18 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
             loop->lpt_decision.times);
 }
 
-/* Splits edge E and inserts INSNS on it.  */
+/* Splits edge E and inserts the sequence of instructions INSNS on it, and
+   returns the newly created block.  If INSNS is NULL_RTX, nothing is changed
+   and NULL is returned instead.  */
 
 basic_block
 split_edge_and_insert (edge e, rtx insns)
 {
-  basic_block bb = split_edge (e); 
-  gcc_assert (insns != NULL_RTX);
+  basic_block bb;
+
+  if (!insns)
+    return NULL;
+  bb = split_edge (e); 
   emit_insn_after (insns, BB_END (bb));
   bb->flags |= BB_SUPERBLOCK;
   return bb;
@@ -1069,6 +1074,10 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
                                          block_label (preheader), p,
                                          NULL_RTX);
 
+      /* We rely on the fact that the compare and jump cannot be optimized out,
+        and hence the cfg we create is correct.  */
+      gcc_assert (branch_code != NULL_RTX);
+
       swtch = split_edge_and_insert (single_pred_edge (swtch), branch_code);
       set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
       single_pred_edge (swtch)->probability = REG_BR_PROB_BASE - p;
@@ -1086,6 +1095,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
       branch_code = compare_and_jump_seq (copy_rtx (niter), const0_rtx, EQ,
                                          block_label (preheader), p,
                                          NULL_RTX);
+      gcc_assert (branch_code != NULL_RTX);
 
       swtch = split_edge_and_insert (single_succ_edge (swtch), branch_code);
       set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);