This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ICE in fixup_reorder_chain, at bb-reorder.c:633


On Thu, Sep 07, 2000 at 07:46:57PM -0400, John David Anglin wrote:
> Here is a test case.  The `if' is necessary for some reason.

Yes, I see why now.  The block after the switch is also the
block after the if.  The if is predicted false, and so the
block after the if is placed next.  Thus when we come to the
switch, the fallthru block has already been placed.

So the correct solution is to add a new jump.  Fixed thus.

> The test case compiles successfully with a version built from a source
> downloaded around the 3rd week of August but not with a source downloaded
> on August 29.

Of course.  -freorder-blocks was made default in the meantime.


r~


        * bb-reorder.c (fixup_reorder_chain): Add jump in new block
        after switch for CASE_DROPS_THROUGH.

Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/bb-reorder.c,v
retrieving revision 1.19
diff -c -p -d -r1.19 bb-reorder.c
*** bb-reorder.c	2000/07/27 17:25:13	1.19
--- bb-reorder.c	2000/09/08 00:21:06
*************** fixup_reorder_chain ()
*** 549,555 ****
    for (bb = BASIC_BLOCK (0); bb ; bb = RBI (bb)->next)
      {
        edge e_fall, e_taken, e;
!       rtx jump_insn, barrier_insn;
        basic_block nb;
  
        if (bb->succ == NULL)
--- 549,555 ----
    for (bb = BASIC_BLOCK (0); bb ; bb = RBI (bb)->next)
      {
        edge e_fall, e_taken, e;
!       rtx jump_insn, barrier_insn, bb_end_insn;
        basic_block nb;
  
        if (bb->succ == NULL)
*************** fixup_reorder_chain ()
*** 564,572 ****
  	else if (! (e->flags & EDGE_EH))
  	  e_taken = e;
  
!       if (GET_CODE (bb->end) == JUMP_INSN)
  	{
! 	  if (any_uncondjump_p (bb->end))
  	    {
  	      /* If the destination is still not next, nothing to do.  */
  	      if (RBI (bb)->index + 1 != RBI (e_taken->dest)->index)
--- 564,573 ----
  	else if (! (e->flags & EDGE_EH))
  	  e_taken = e;
  
!       bb_end_insn = bb->end;
!       if (GET_CODE (bb_end_insn) == JUMP_INSN)
  	{
! 	  if (any_uncondjump_p (bb_end_insn))
  	    {
  	      /* If the destination is still not next, nothing to do.  */
  	      if (RBI (bb)->index + 1 != RBI (e_taken->dest)->index)
*************** fixup_reorder_chain ()
*** 582,588 ****
  			 bb->index, RBI (bb)->index);
  	      continue;
  	    }
! 	  else if (any_condjump_p (bb->end))
  	    {
  	      /* If the old fallthru is still next, nothing to do.  */
  	      if (RBI (bb)->index + 1 == RBI (e_fall->dest)->index
--- 583,589 ----
  			 bb->index, RBI (bb)->index);
  	      continue;
  	    }
! 	  else if (any_condjump_p (bb_end_insn))
  	    {
  	      /* If the old fallthru is still next, nothing to do.  */
  	      if (RBI (bb)->index + 1 == RBI (e_fall->dest)->index
*************** fixup_reorder_chain ()
*** 596,605 ****
  		 edge based on known or assumed probability.  */
  	      if (RBI (bb)->index + 1 != RBI (e_taken->dest)->index)
  		{
! 		  rtx note = find_reg_note (bb->end, REG_BR_PROB, 0);
  		  if (note
  		      && INTVAL (XEXP (note, 0)) < REG_BR_PROB_BASE / 2
! 		      && invert_jump (bb->end, label_for_bb (e_fall->dest), 0))
  		    {
  		      e_fall->flags &= ~EDGE_FALLTHRU;
  		      e_taken->flags |= EDGE_FALLTHRU;
--- 597,607 ----
  		 edge based on known or assumed probability.  */
  	      if (RBI (bb)->index + 1 != RBI (e_taken->dest)->index)
  		{
! 		  rtx note = find_reg_note (bb_end_insn, REG_BR_PROB, 0);
  		  if (note
  		      && INTVAL (XEXP (note, 0)) < REG_BR_PROB_BASE / 2
! 		      && invert_jump (bb_end_insn,
! 				      label_for_bb (e_fall->dest), 0))
  		    {
  		      e_fall->flags &= ~EDGE_FALLTHRU;
  		      e_taken->flags |= EDGE_FALLTHRU;
*************** fixup_reorder_chain ()
*** 609,622 ****
  
  	      /* Otherwise we can try to invert the jump.  This will 
  		 basically never fail, however, keep up the pretense.  */
! 	      else if (invert_jump (bb->end, label_for_bb (e_fall->dest), 0))
  		{
  		  e_fall->flags &= ~EDGE_FALLTHRU;
  		  e_taken->flags |= EDGE_FALLTHRU;
  		  continue;
  		}
  	    }
! 	  else if (returnjump_p (bb->end))
  	    continue;
  	  else
  	    {
--- 611,625 ----
  
  	      /* Otherwise we can try to invert the jump.  This will 
  		 basically never fail, however, keep up the pretense.  */
! 	      else if (invert_jump (bb_end_insn,
! 				    label_for_bb (e_fall->dest), 0))
  		{
  		  e_fall->flags &= ~EDGE_FALLTHRU;
  		  e_taken->flags |= EDGE_FALLTHRU;
  		  continue;
  		}
  	    }
! 	  else if (returnjump_p (bb_end_insn))
  	    continue;
  	  else
  	    {
*************** fixup_reorder_chain ()
*** 629,636 ****
  		 tablejump, the fallthru block should not have moved.  */
  	      if (RBI (bb)->index + 1 == RBI (e_fall->dest)->index)
  		continue;
! #endif
  	      abort ();
  	    }
  	}
        else
--- 632,641 ----
  		 tablejump, the fallthru block should not have moved.  */
  	      if (RBI (bb)->index + 1 == RBI (e_fall->dest)->index)
  		continue;
! 	      bb_end_insn = skip_insns_after_block (bb);
! #else
  	      abort ();
+ #endif
  	    }
  	}
        else
*************** fixup_reorder_chain ()
*** 653,659 ****
  	    {
  	      e_fall->flags &= ~EDGE_FALLTHRU;
  
! 	      jump_insn = emit_jump_to_block_after (e_fall->dest, bb->end);
  	      bb->end = jump_insn;
  	      barrier_insn = emit_barrier_after (jump_insn);
  	      RBI (bb)->eff_end = barrier_insn;
--- 658,664 ----
  	    {
  	      e_fall->flags &= ~EDGE_FALLTHRU;
  
! 	      jump_insn = emit_jump_to_block_after (e_fall->dest, bb_end_insn);
  	      bb->end = jump_insn;
  	      barrier_insn = emit_barrier_after (jump_insn);
  	      RBI (bb)->eff_end = barrier_insn;
*************** fixup_reorder_chain ()
*** 664,670 ****
        /* We got here if we need to add a new jump insn in a new block
  	 across the edge e_fall.  */
  
!       jump_insn = emit_jump_to_block_after (e_fall->dest, bb->end);
        barrier_insn = emit_barrier_after (jump_insn);
  
        VARRAY_GROW (basic_block_info, ++n_basic_blocks);
--- 669,675 ----
        /* We got here if we need to add a new jump insn in a new block
  	 across the edge e_fall.  */
  
!       jump_insn = emit_jump_to_block_after (e_fall->dest, bb_end_insn);
        barrier_insn = emit_barrier_after (jump_insn);
  
        VARRAY_GROW (basic_block_info, ++n_basic_blocks);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]