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]

Re: [PATCH] Fix (?) load_kills_store


Hello,

> > can mem be inside STRICT_LOW_PART?
> 
> No, I guess not.  That doesn't make any sense.
> 
> > what about this patch (completely untested)?
> 
> Yes, this looks reasonable to me.  In load_kills_store, and in
> store_killed_in_insn, the "if (after)" checks should instead be "if
> (!after)".  Otherwise it looks OK.  You could simplify load_kills_store
> a little.  No need for the inner if statements, just directly return the
> result of true_dependence/anti_dependence.

here is the patch, bootstrapped and regtested. OK?

Zdenek

	* gcse.c (load_kills_store, find_loads, store_killed_in_insn,
	store_killed_after, store_killed_before): Keep track of the correct
	dependency function to use.

Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.257
diff -c -3 -p -r1.257 gcse.c
*** gcse.c	6 Jul 2003 06:15:35 -0000	1.257
--- gcse.c	9 Jul 2003 22:39:36 -0000
*************** static rtx extract_mentioned_regs (rtx);
*** 682,690 ****
  static rtx extract_mentioned_regs_helper (rtx, rtx);
  static void find_moveable_store (rtx, int *, int *);
  static int compute_store_table (void);
! static bool load_kills_store (rtx, rtx);
! static bool find_loads (rtx, rtx);
! static bool store_killed_in_insn (rtx, rtx, rtx);
  static bool store_killed_after (rtx, rtx, rtx, basic_block, int *, rtx *);
  static bool store_killed_before (rtx, rtx, rtx, basic_block, int *);
  static void build_store_vectors (void);
--- 682,690 ----
  static rtx extract_mentioned_regs_helper (rtx, rtx);
  static void find_moveable_store (rtx, int *, int *);
  static int compute_store_table (void);
! static bool load_kills_store (rtx, rtx, int);
! static bool find_loads (rtx, rtx, int);
! static bool store_killed_in_insn (rtx, rtx, rtx, int);
  static bool store_killed_after (rtx, rtx, rtx, basic_block, int *, rtx *);
  static bool store_killed_before (rtx, rtx, rtx, basic_block, int *);
  static void build_store_vectors (void);
*************** compute_store_table (void)
*** 7186,7206 ****
    return ret;
  }
  
! /* Check to see if the load X is aliased with STORE_PATTERN.  */
  
  static bool
! load_kills_store (rtx x, rtx store_pattern)
  {
!   if (true_dependence (x, GET_MODE (x), store_pattern, rtx_addr_varies_p))
!     return true;
!   return false;
  }
  
  /* Go through the entire insn X, looking for any loads which might alias
!    STORE_PATTERN.  Return true if found.  */
  
  static bool
! find_loads (rtx x, rtx store_pattern)
  {
    const char * fmt;
    int i, j;
--- 7186,7212 ----
    return ret;
  }
  
! /* Check to see if the load X is aliased with STORE_PATTERN.
!    AFTER is true if we are checking the case when STORE_PATTERN occurs
!    after the X.  */
  
  static bool
! load_kills_store (rtx x, rtx store_pattern, int after)
  {
!   if (after)
!     return anti_dependence (x, store_pattern);
!   else
!     return true_dependence (store_pattern, GET_MODE (store_pattern), x,
! 			    rtx_addr_varies_p);
  }
  
  /* Go through the entire insn X, looking for any loads which might alias
!    STORE_PATTERN.  Return true if found.
!    AFTER is true if we are checking the case when STORE_PATTERN occurs
!    after the insn X.  */
  
  static bool
! find_loads (rtx x, rtx store_pattern, int after)
  {
    const char * fmt;
    int i, j;
*************** find_loads (rtx x, rtx store_pattern)
*** 7214,7220 ****
  
    if (GET_CODE (x) == MEM)
      {
!       if (load_kills_store (x, store_pattern))
  	return true;
      }
  
--- 7220,7226 ----
  
    if (GET_CODE (x) == MEM)
      {
!       if (load_kills_store (x, store_pattern, after))
  	return true;
      }
  
*************** find_loads (rtx x, rtx store_pattern)
*** 7224,7242 ****
    for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0 && !ret; i--)
      {
        if (fmt[i] == 'e')
! 	ret |= find_loads (XEXP (x, i), store_pattern);
        else if (fmt[i] == 'E')
  	for (j = XVECLEN (x, i) - 1; j >= 0; j--)
! 	  ret |= find_loads (XVECEXP (x, i, j), store_pattern);
      }
    return ret;
  }
  
  /* Check if INSN kills the store pattern X (is aliased with it).
!    Return true if it it does.  */
  
  static bool
! store_killed_in_insn (rtx x, rtx x_regs, rtx insn)
  {
    rtx reg, base;
  
--- 7230,7249 ----
    for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0 && !ret; i--)
      {
        if (fmt[i] == 'e')
! 	ret |= find_loads (XEXP (x, i), store_pattern, after);
        else if (fmt[i] == 'E')
  	for (j = XVECLEN (x, i) - 1; j >= 0; j--)
! 	  ret |= find_loads (XVECEXP (x, i, j), store_pattern, after);
      }
    return ret;
  }
  
  /* Check if INSN kills the store pattern X (is aliased with it).
!    AFTER is true if we are checking the case when store X occurs
!    after the insn.  Return true if it it does.  */
  
  static bool
! store_killed_in_insn (rtx x, rtx x_regs, rtx insn, int after)
  {
    rtx reg, base;
  
*************** store_killed_in_insn (rtx x, rtx x_regs,
*** 7268,7282 ****
    if (GET_CODE (PATTERN (insn)) == SET)
      {
        rtx pat = PATTERN (insn);
        /* Check for memory stores to aliased objects.  */
!       if (GET_CODE (SET_DEST (pat)) == MEM && !expr_equiv_p (SET_DEST (pat), x))
! 	/* pretend its a load and check for aliasing.  */
! 	if (find_loads (SET_DEST (pat), x))
! 	  return true;
!       return find_loads (SET_SRC (pat), x);
      }
    else
!     return find_loads (PATTERN (insn), x);
  }
  
  /* Returns true if the expression X is loaded or clobbered on or after INSN
--- 7275,7305 ----
    if (GET_CODE (PATTERN (insn)) == SET)
      {
        rtx pat = PATTERN (insn);
+       rtx dest = SET_DEST (pat);
+ 
+       if (GET_CODE (dest) == SIGN_EXTRACT
+ 	  || GET_CODE (dest) == ZERO_EXTRACT)
+ 	dest = XEXP (dest, 0);
+ 
        /* Check for memory stores to aliased objects.  */
!       if (GET_CODE (dest) == MEM
! 	  && !expr_equiv_p (dest, x))
! 	{
! 	  if (after)
! 	    {
! 	      if (output_dependence (dest, x))
! 		return true;
! 	    }
! 	  else
! 	    {
! 	      if (output_dependence (x, dest))
! 		return true;
! 	    }
! 	}
!       return find_loads (SET_SRC (pat), x, after);
      }
    else
!     return find_loads (PATTERN (insn), x, after);
  }
  
  /* Returns true if the expression X is loaded or clobbered on or after INSN
*************** store_killed_after (rtx x, rtx x_regs, r
*** 7300,7306 ****
  
    /* Scan from the end, so that fail_insn is determined correctly.  */
    for (act = last; act != PREV_INSN (insn); act = PREV_INSN (act))
!     if (store_killed_in_insn (x, x_regs, act))
        {
  	if (fail_insn)
  	  *fail_insn = act;
--- 7323,7329 ----
  
    /* Scan from the end, so that fail_insn is determined correctly.  */
    for (act = last; act != PREV_INSN (insn); act = PREV_INSN (act))
!     if (store_killed_in_insn (x, x_regs, act, false))
        {
  	if (fail_insn)
  	  *fail_insn = act;
*************** store_killed_before (rtx x, rtx x_regs, 
*** 7323,7329 ****
      return true;
  
    for ( ; insn != PREV_INSN (first); insn = PREV_INSN (insn))
!     if (store_killed_in_insn (x, x_regs, insn))
        return true;
  
    return false;
--- 7346,7352 ----
      return true;
  
    for ( ; insn != PREV_INSN (first); insn = PREV_INSN (insn))
!     if (store_killed_in_insn (x, x_regs, insn, true))
        return true;
  
    return false;


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