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]
Other format: [Raw text]

RFA: redirect_jump_1: fix REG_EQUAL notes


running ce1 in 3.4.3 with register liveness info has triggered a latent bug while compiling zsh:

This code in ifcvt.c:dead_or_predicable calls redirect_jump_1:

no_body:
 /* We don't want to use normal invert_jump or redirect_jump because
    we don't want to delete_insn called.  Also, we want to do our own
    change group management.  */

 old_dest = JUMP_LABEL (jump);
 if (other_bb != new_dest)
   {
     new_label = block_label (new_dest);
     if (reversep
         ? ! invert_jump_1 (jump, new_label)
         : ! redirect_jump_1 (jump, new_label))
       goto cancel;
   }

When the jump has a REG_EQUAL note, the note remains unchanged, so
cse can use it to make new jumps that go to the deleted label at the start of
else_bb, which leads to an ICE later in verify_flow_info.


The attached patch fixes this problem for redirect_jump_1.

From looking at the source, we have a similar problem in invert_jump_1.
I can easily whip up a patch to make it register a change to use
reversed_comparison_code, with a fallback of registering a change to
remove the note; however, I don't have a testcase handy to see that the code
will do the right thing.


2005-02-28  J"orn Rennecke <joern.rennecke@st.com>

	* jump.c (redirect_jump_1): Update labels in any REG_EQUAL note.

Index: jump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/jump.c,v
retrieving revision 1.253
diff -p -r1.253 jump.c
*** jump.c	24 Nov 2004 11:32:23 -0000	1.253
--- jump.c	28 Feb 2005 18:13:21 -0000
*************** int
*** 1597,1603 ****
  redirect_jump_1 (rtx jump, rtx nlabel)
  {
    int ochanges = num_validated_changes ();
!   rtx *loc;
  
    if (GET_CODE (PATTERN (jump)) == PARALLEL)
      loc = &XVECEXP (PATTERN (jump), 0, 0);
--- 1597,1603 ----
  redirect_jump_1 (rtx jump, rtx nlabel)
  {
    int ochanges = num_validated_changes ();
!   rtx *loc, note;
  
    if (GET_CODE (PATTERN (jump)) == PARALLEL)
      loc = &XVECEXP (PATTERN (jump), 0, 0);
*************** redirect_jump_1 (rtx jump, rtx nlabel)
*** 1605,1611 ****
      loc = &PATTERN (jump);
  
    redirect_exp_1 (loc, JUMP_LABEL (jump), nlabel, jump);
!   return num_validated_changes () > ochanges;
  }
  
  /* Make JUMP go to NLABEL instead of where it jumps now.  If the old
--- 1605,1624 ----
      loc = &PATTERN (jump);
  
    redirect_exp_1 (loc, JUMP_LABEL (jump), nlabel, jump);
!   if (num_validated_changes () == ochanges)
!     return 0;
! 
!   /* Update labels in any REG_EQUAL note.  */
!   for (loc = &REG_NOTES (jump); (note = *loc); loc = &XEXP (note, 1))
!     if (GET_MODE (note) == REG_EQUAL)
!       {
! 	if (nlabel)
! 	  redirect_exp_1 (&XEXP (note, 0), JUMP_LABEL (jump), nlabel, jump);
! 	else
! 	  validate_change (jump, loc, XEXP (note, 1), 1);
! 	break;
!       }
!   return 1;
  }
  
  /* Make JUMP go to NLABEL instead of where it jumps now.  If the old

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