delay slot bug

Ken Rose rose@netcom.com
Thu Apr 23 15:01:00 GMT 1998


Apparently, I goofed with my previous post.  The patch for the delay slot bug 
perhaps follows

Ken

*** reorg.c	Tue Sep 23 00:14:07 1997
--- /server_pc/c-drive/users/kenr/gcc-2.8.1/reorg.c	Thu Feb 26 05:39:04 1998
***************
*** 115,122 ****
     The HP-PA can conditionally nullify insns, providing a similar
     effect to the ARM, differing mostly in which insn is "in charge".   */
  
- #include <stdio.h>
  #include "config.h"
  #include "rtl.h"
  #include "insn-config.h"
  #include "conditions.h"
--- 115,122 ----
     The HP-PA can conditionally nullify insns, providing a similar
     effect to the ARM, differing mostly in which insn is "in charge".   */
  
  #include "config.h"
+ #include <stdio.h>
  #include "rtl.h"
  #include "insn-config.h"
  #include "conditions.h"
***************
*** 266,272 ****
  static void mark_target_live_regs PROTO((rtx, struct resources *));
  static void fill_simple_delay_slots PROTO((rtx, int));
  static rtx fill_slots_from_thread PROTO((rtx, rtx, rtx, rtx, int, int,
! 					 int, int, int, int *));
  static void fill_eager_delay_slots PROTO((rtx));
  static void relax_delay_slots	PROTO((rtx));
  static void make_return_insns	PROTO((rtx));
--- 266,272 ----
  static void mark_target_live_regs PROTO((rtx, struct resources *));
  static void fill_simple_delay_slots PROTO((rtx, int));
  static rtx fill_slots_from_thread PROTO((rtx, rtx, rtx, rtx, int, int,
! 					 int, int, int, int *, rtx));
  static void fill_eager_delay_slots PROTO((rtx));
  static void relax_delay_slots	PROTO((rtx));
  static void make_return_insns	PROTO((rtx));
***************
*** 274,280 ****
  static int redirect_with_delay_list_safe_p PROTO ((rtx, rtx, rtx));
  
  /* Given X, some rtl, and RES, a pointer to a `struct resource', mark
!    which resources are references by the insn.  If INCLUDE_CALLED_ROUTINE
     is TRUE, resources used by the called routine will be included for
     CALL_INSNs.  */
  
--- 274,280 ----
  static int redirect_with_delay_list_safe_p PROTO ((rtx, rtx, rtx));
  
  /* Given X, some rtl, and RES, a pointer to a `struct resource', mark
!    which resources are references by the insn.  If INCLUDE_DELAYED_EFFECTS
     is TRUE, resources used by the called routine will be included for
     CALL_INSNs.  */
  
***************
*** 487,495 ****
        }
  }
  
! /* Given X, a part of an insn, and a pointer to a `struct resource', RES,
!    indicate which resources are modified by the insn. If INCLUDE_CALLED_ROUTINE
!    is nonzero, also mark resources potentially set by the called routine.
  
     If IN_DEST is nonzero, it means we are inside a SET.  Otherwise,
     objects are being referenced instead of set.
--- 487,496 ----
        }
  }
  
! /* Given X, a part of an insn, and a pointer to a `struct resource',
!    RES, indicate which resources are modified by the insn. If
!    INCLUDE_DELAYED_EFFECTS is nonzero, also mark resources potentially
!    set by the called routine.
  
     If IN_DEST is nonzero, it means we are inside a SET.  Otherwise,
     objects are being referenced instead of set.
***************
*** 740,746 ****
  }
  
  /* Return TRUE if any resource marked in RES, a `struct resources', is
!    referenced by INSN.  If INCLUDE_CALLED_ROUTINE is set, return if the called
     routine is using those resources.
  
     We compute this by computing all the resources referenced by INSN and
--- 741,747 ----
  }
  
  /* Return TRUE if any resource marked in RES, a `struct resources', is
!    referenced by INSN.  If INCLUDE_DELAYED_EFFECTS is set, return if the called
     routine is using those resources.
  
     We compute this by computing all the resources referenced by INSN and
***************
*** 762,768 ****
  }
  
  /* Return TRUE if INSN modifies resources that are marked in RES.
!    INCLUDE_CALLED_ROUTINE is set if the actions of that routine should be
     included.   CC0 is only modified if it is explicitly set; see comments
     in front of mark_set_resources for details.  */
  
--- 763,769 ----
  }
  
  /* Return TRUE if INSN modifies resources that are marked in RES.
!    INCLUDE_DELAYED_EFFECTS is set if the actions of that routine should be
     included.   CC0 is only modified if it is explicitly set; see comments
     in front of mark_set_resources for details.  */
  
***************
*** 3322,3328 ****
  				    NULL, 1, 1,
  				    own_thread_p (JUMP_LABEL (insn),
  						  JUMP_LABEL (insn), 0),
! 				    0, slots_to_fill, &slots_filled);
  
        if (delay_list)
  	unfilled_slots_base[i]
--- 3323,3330 ----
  				    NULL, 1, 1,
  				    own_thread_p (JUMP_LABEL (insn),
  						  JUMP_LABEL (insn), 0),
! 				    0, slots_to_fill, &slots_filled,
! 				    delay_list);
  
        if (delay_list)
  	unfilled_slots_base[i]
***************
*** 3452,3458 ****
  static rtx
  fill_slots_from_thread (insn, condition, thread, opposite_thread, likely,
  			thread_if_true, own_thread, own_opposite_thread,
! 			slots_to_fill, pslots_filled)
       rtx insn;
       rtx condition;
       rtx thread, opposite_thread;
--- 3454,3460 ----
  static rtx
  fill_slots_from_thread (insn, condition, thread, opposite_thread, likely,
  			thread_if_true, own_thread, own_opposite_thread,
! 			slots_to_fill, pslots_filled, delay_list)
       rtx insn;
       rtx condition;
       rtx thread, opposite_thread;
***************
*** 3460,3468 ****
       int thread_if_true;
       int own_thread, own_opposite_thread;
       int slots_to_fill, *pslots_filled;
  {
    rtx new_thread;
-   rtx delay_list = 0;
    struct resources opposite_needed, set, needed;
    rtx trial;
    int lose = 0;
--- 3462,3470 ----
       int thread_if_true;
       int own_thread, own_opposite_thread;
       int slots_to_fill, *pslots_filled;
+      rtx delay_list;
  {
    rtx new_thread;
    struct resources opposite_needed, set, needed;
    rtx trial;
    int lose = 0;
***************
*** 3479,3485 ****
    /* If our thread is the end of subroutine, we can't get any delay
       insns from that.  */
    if (thread == 0)
!     return 0;
  
    /* If this is an unconditional branch, nothing is needed at the
       opposite thread.  Otherwise, compute what is needed there.  */
--- 3481,3487 ----
    /* If our thread is the end of subroutine, we can't get any delay
       insns from that.  */
    if (thread == 0)
!       return delay_list;
  
    /* If this is an unconditional branch, nothing is needed at the
       opposite thread.  Otherwise, compute what is needed there.  */
***************
*** 3636,3641 ****
--- 3638,3645 ----
  
  		  delay_list = add_to_delay_list (temp, delay_list);
  
+ 		  mark_set_resources (trial, &opposite_needed, 0, 1);
+ 
  		  if (slots_to_fill == ++(*pslots_filled))
  		    {
  		      /* Even though we have filled all the slots, we
***************
*** 3705,3711 ****
      {
        /* If this is the `true' thread, we will want to follow the jump,
  	 so we can only do this if we have taken everything up to here.  */
!       if (thread_if_true && trial == new_thread)
  	delay_list
  	  = steal_delay_list_from_target (insn, condition, PATTERN (trial),
  					  delay_list, &set, &needed,
--- 3709,3717 ----
      {
        /* If this is the `true' thread, we will want to follow the jump,
  	 so we can only do this if we have taken everything up to here.  */
!       if (thread_if_true && trial == new_thread
! 	  && ! insn_references_resource_p (XVECEXP (PATTERN (trial), 0, 0),
! 					   &opposite_needed, 0))
  	delay_list
  	  = steal_delay_list_from_target (insn, condition, PATTERN (trial),
  					  delay_list, &set, &needed,
***************
*** 3905,3911 ****
  	    = fill_slots_from_thread (insn, condition, insn_at_target,
  				      fallthrough_insn, prediction == 2, 1,
  				      own_target, own_fallthrough,
! 				      slots_to_fill, &slots_filled);
  
  	  if (delay_list == 0 && own_fallthrough)
  	    {
--- 3911,3918 ----
  	    = fill_slots_from_thread (insn, condition, insn_at_target,
  				      fallthrough_insn, prediction == 2, 1,
  				      own_target, own_fallthrough,
! 				      slots_to_fill, &slots_filled,
! 				      delay_list);
  
  	  if (delay_list == 0 && own_fallthrough)
  	    {
***************
*** 3920,3926 ****
  		= fill_slots_from_thread (insn, condition, fallthrough_insn,
  					  insn_at_target, 0, 0,
  					  own_fallthrough, own_target,
! 					  slots_to_fill, &slots_filled);
  	    }
  	}
        else
--- 3927,3934 ----
  		= fill_slots_from_thread (insn, condition, fallthrough_insn,
  					  insn_at_target, 0, 0,
  					  own_fallthrough, own_target,
! 					  slots_to_fill, &slots_filled,
! 					  delay_list);
  	    }
  	}
        else
***************
*** 3930,3943 ****
  	      = fill_slots_from_thread (insn, condition, fallthrough_insn,
  					insn_at_target, 0, 0,
  					own_fallthrough, own_target,
! 					slots_to_fill, &slots_filled);
  
  	  if (delay_list == 0)
  	    delay_list
  	      = fill_slots_from_thread (insn, condition, insn_at_target,
  					next_active_insn (insn), 0, 1,
  					own_target, own_fallthrough,
! 					slots_to_fill, &slots_filled);
  	}
  
        if (delay_list)
--- 3938,3953 ----
  	      = fill_slots_from_thread (insn, condition, fallthrough_insn,
  					insn_at_target, 0, 0,
  					own_fallthrough, own_target,
! 					slots_to_fill, &slots_filled,
! 					delay_list);
  
  	  if (delay_list == 0)
  	    delay_list
  	      = fill_slots_from_thread (insn, condition, insn_at_target,
  					next_active_insn (insn), 0, 1,
  					own_target, own_fallthrough,
! 					slots_to_fill, &slots_filled,
! 					delay_list);
  	}
  
        if (delay_list)
***************
*** 4616,4638 ****
  	      fprintf (file, "\n");
  	    }
  	}
-     }
- 
-   /* For all JUMP insns, fill in branch prediction notes, so that during
-      assembler output a target can set branch prediction bits in the code.
-      We have to do this now, as up until this point the destinations of
-      JUMPS can be moved around and changed, but past right here that cannot
-      happen.  */
-   for (insn = first; insn; insn = NEXT_INSN (insn))
-     {
-       int pred_flags;
- 
-       if (GET_CODE (insn) != JUMP_INSN)
- 	continue;
- 
-       pred_flags = get_jump_flags (insn, JUMP_LABEL (insn));
-       REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_BR_PRED,
- 				  GEN_INT (pred_flags), REG_NOTES (insn));
      }
  }
  #endif /* DELAY_SLOTS */
--- 4626,4631 ----



More information about the Gcc-bugs mailing list