[patch] for PR 29924

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Wed Nov 22 00:04:00 GMT 2006


Hello,

split_edge_and_insert now assumes that the insns argument is not NULL,
which turns out not to be the case in its uses in modulo scheduling.
This patch makes split_edge_and_insert handle this case, and adds some
comments explaining why the insns cannot be NULL on the other places
where this function is used.

Bootstrapped & regtested on i686, I will commit this in a moment.

Zdenek

	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.

Index: loop-unroll.c
===================================================================
*** loop-unroll.c	(revision 119043)
--- loop-unroll.c	(working copy)
*************** decide_unroll_runtime_iterations (struct
*** 899,911 ****
  	     loop->lpt_decision.times);
  }
  
! /* Splits edge E and inserts INSNS on it.  */
  
  basic_block
  split_edge_and_insert (edge e, rtx insns)
  {
!   basic_block bb = split_edge (e); 
!   gcc_assert (insns != NULL_RTX);
    emit_insn_after (insns, BB_END (bb));
    bb->flags |= BB_SUPERBLOCK;
    return bb;
--- 899,916 ----
  	     loop->lpt_decision.times);
  }
  
! /* 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;
! 
!   if (!insns)
!     return NULL;
!   bb = split_edge (e); 
    emit_insn_after (insns, BB_END (bb));
    bb->flags |= BB_SUPERBLOCK;
    return bb;
*************** unroll_loop_runtime_iterations (struct l
*** 1069,1074 ****
--- 1074,1083 ----
  					  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;
*************** unroll_loop_runtime_iterations (struct l
*** 1086,1091 ****
--- 1095,1101 ----
        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);
Index: loop-doloop.c
===================================================================
*** loop-doloop.c	(revision 119043)
--- loop-doloop.c	(working copy)
*************** add_test (rtx cond, edge *e, basic_block
*** 248,254 ****
    do_compare_rtx_and_jump (op0, op1, code, 0, mode, NULL_RTX, NULL_RTX, label);
  
    jump = get_last_insn ();
!   if (!JUMP_P (jump))
      {
        /* The condition is always false and the jump was optimized out.  */
        end_sequence ();
--- 248,254 ----
    do_compare_rtx_and_jump (op0, op1, code, 0, mode, NULL_RTX, NULL_RTX, label);
  
    jump = get_last_insn ();
!   if (!jump || !JUMP_P (jump))
      {
        /* The condition is always false and the jump was optimized out.  */
        end_sequence ();
*************** add_test (rtx cond, edge *e, basic_block
*** 257,262 ****
--- 257,266 ----
  
    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);
  



More information about the Gcc-patches mailing list