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] Store motion rewrite


Hello,

> Richard Henderson wrote:
> > 
> > On Tue, Apr 01, 2003 at 09:01:48PM +0100, Joern Rennecke wrote:
> > > Is that a joke?
> > 
> > No.  What do you have in mind as an alternate solution?
> 
> At the least, we should put a FIXME comment there that we completely
> disable the effect of the constant type modifier of functions on this
> optimization for RISC CPUs.
> Of course, a better solution would be to fix the problem now, at least for
> the common cases, either by using du chains, or by exploiting information
> from the alias set info in the MEM.

just bootstrapping/regtesting it, ok if it passes?

Zdenek

Changelog:
	* alias.c (find_base_term): Export.
	* rtl.h (find_base_term): Declare.
	* gcse.c (find_moveable_store): Handling of arguments passed to
	constant functions moved...
	(store_killed_in_insn): ... here.  Use info from alias analysis.

Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.190
diff -c -3 -p -r1.190 alias.c
*** alias.c	18 Mar 2003 18:24:07 -0000	1.190
--- alias.c	1 Apr 2003 22:49:02 -0000
*************** rtx get_addr				PARAMS ((rtx));
*** 98,104 ****
  static int memrefs_conflict_p		PARAMS ((int, rtx, int, rtx,
  						 HOST_WIDE_INT));
  static void record_set			PARAMS ((rtx, rtx, void *));
- static rtx find_base_term		PARAMS ((rtx));
  static int base_alias_check		PARAMS ((rtx, rtx, enum machine_mode,
  						 enum machine_mode));
  static rtx find_base_value		PARAMS ((rtx));
--- 98,103 ----
*************** find_symbolic_term (x)
*** 1299,1305 ****
    return 0;
  }
  
! static rtx
  find_base_term (x)
       rtx x;
  {
--- 1298,1304 ----
    return 0;
  }
  
! rtx
  find_base_term (x)
       rtx x;
  {
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.242
diff -c -3 -p -r1.242 gcse.c
*** gcse.c	1 Apr 2003 20:23:54 -0000	1.242
--- gcse.c	1 Apr 2003 22:49:02 -0000
*************** find_moveable_store (insn, regs_set_befo
*** 7098,7113 ****
    if (flag_exceptions && may_trap_p (dest))
      return;
      
-   /* Do not consider MEMs that mention stack pointer; in the following
-      we rely on that constant functions do not read memory, which of course
-      does not include their arguments if passed on stack.
-      
-      Note that this is not quite correct -- we may use other registers
-      to address stack.  See store_killed_in_insn for handling of this
-      case.  */
-   if (reg_mentioned_p (stack_pointer_rtx, dest))
-     return;
- 
    ptr = ldst_entry (dest);
    if (!ptr->pattern_regs)
      ptr->pattern_regs = extract_mentioned_regs (dest);
--- 7098,7103 ----
*************** static bool
*** 7358,7363 ****
--- 7348,7355 ----
  store_killed_in_insn (x, x_regs, insn)
       rtx x, x_regs, insn;
  {
+   rtx reg, base;
+ 
    if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
      return false;
  
*************** store_killed_in_insn (x, x_regs, insn)
*** 7368,7378 ****
        if (! CONST_OR_PURE_CALL_P (insn) || pure_call_p (insn))
  	return true;
  
!       /* But even a const call reads its parameters.  It is not trivial
! 	 check that base of the mem is not related to stack pointer,
! 	 so unless it contains no registers, just assume it may.  */
!       if (x_regs)
! 	return true;
  
        return false;
      }
--- 7360,7376 ----
        if (! CONST_OR_PURE_CALL_P (insn) || pure_call_p (insn))
  	return true;
  
!       /* But even a const call reads its parameters.  Check whether the
! 	 base of some of registers used in mem is stack pointer.  */
!       for (reg = x_regs; reg; reg = XEXP (reg, 1))
! 	{
! 	  base = find_base_term (reg);
! 	  if (!base
! 	      || (GET_CODE (base) == ADDRESS
! 		  && GET_MODE (base) == Pmode
! 		  && XEXP (base, 0) == stack_pointer_rtx))
! 	    return true;
! 	}
  
        return false;
      }
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.390
diff -c -3 -p -r1.390 rtl.h
*** rtl.h	24 Mar 2003 17:53:29 -0000	1.390
--- rtl.h	1 Apr 2003 22:49:03 -0000
*************** extern void init_alias_analysis		PARAMS 
*** 2281,2286 ****
--- 2281,2287 ----
  extern void end_alias_analysis		PARAMS ((void));
  extern rtx addr_side_effect_eval	PARAMS ((rtx, int, int));
  extern bool memory_modified_in_insn_p	PARAMS ((rtx, rtx));
+ extern rtx find_base_term		PARAMS ((rtx));
  
  /* In sibcall.c */
  typedef enum {


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