This is the mail archive of the gcc-prs@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: optimization/6233: simple loop miscompilation


The following reply was made to PR optimization/6233; it has been noted by GNATS.

From: Alan Modra <amodra@bigpond.net.au>
To: Richard Henderson <rth@redhat.com>, gcc-gnats@gcc.gnu.org,
  gcc-patches@gcc.gnu.org
Cc:  
Subject: Re: optimization/6233: simple loop miscompilation
Date: Wed, 10 Apr 2002 10:32:37 +0930

 On Tue, Apr 09, 2002 at 05:41:07PM -0700, Richard Henderson wrote:
 > On Wed, Apr 10, 2002 at 09:30:14AM +0930, Alan Modra wrote:
 > > Sledgehammer to crack a nut?  Should I instead specifically search
 > > for the use_mem_scratch?
 > 
 > Please.
 
 OK.  i686-linux native bootstrap and reg test in progress.
 
 	* rtlanal.c (pure_call_p): New function.
 	* rtl.h (pure_call_p): Declare.
 	* loop.c (prescan_loop): Use it to set has_nonconst_call.
 
 Index: gcc/loop.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/loop.c,v
 retrieving revision 1.394
 diff -u -p -r1.394 loop.c
 --- gcc/loop.c	3 Apr 2002 07:56:44 -0000	1.394
 +++ gcc/loop.c	10 Apr 2002 00:56:54 -0000
 @@ -2493,6 +2493,8 @@ prescan_loop (loop)
  	      loop_info->unknown_address_altered = 1;
  	      loop_info->has_nonconst_call = 1;
  	    }
 +	  else if (pure_call_p (insn))
 +	    loop_info->has_nonconst_call = 1;
  	  loop_info->has_call = 1;
  	  if (can_throw_internal (insn))
  	    loop_info->has_multiple_exit_targets = 1;
 Index: gcc/rtl.h
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
 retrieving revision 1.337
 diff -u -p -r1.337 rtl.h
 --- gcc/rtl.h	1 Apr 2002 03:18:49 -0000	1.337
 +++ gcc/rtl.h	10 Apr 2002 00:56:56 -0000
 @@ -1502,6 +1502,7 @@ extern rtx find_reg_equal_equiv_note	PAR
  extern int find_reg_fusage		PARAMS ((rtx, enum rtx_code, rtx));
  extern int find_regno_fusage		PARAMS ((rtx, enum rtx_code,
  						 unsigned int));
 +extern int pure_call_p			PARAMS ((rtx));
  extern void remove_note			PARAMS ((rtx, rtx));
  extern int side_effects_p		PARAMS ((rtx));
  extern int volatile_refs_p		PARAMS ((rtx));
 Index: gcc/rtlanal.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
 retrieving revision 1.130
 diff -u -p -r1.130 rtlanal.c
 --- gcc/rtlanal.c	28 Mar 2002 12:25:18 -0000	1.130
 +++ gcc/rtlanal.c	10 Apr 2002 00:56:58 -0000
 @@ -2011,6 +2011,31 @@ find_regno_fusage (insn, code, regno)
  
    return 0;
  }
 +
 +/* Return true if INSN is a call to a pure function.  */
 +
 +int
 +pure_call_p (insn)
 +     rtx insn;
 +{
 +  rtx link;
 +
 +  if (GET_CODE (insn) != CALL_INSN || ! CONST_OR_PURE_CALL_P (insn))
 +    return 0;
 +
 +  /* Look for the note that differentiates const and pure functions.  */
 +  for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
 +    {
 +      rtx u, m;
 +
 +      if (GET_CODE (u = XEXP (link, 0)) == USE
 +	  && GET_CODE (m = XEXP (u, 0)) == MEM && GET_MODE (m) == BLKmode
 +	  && GET_CODE (XEXP (m, 0)) == SCRATCH)
 +	return 1;
 +    }
 +
 +  return 0;
 +}
  
  /* Remove register note NOTE from the REG_NOTES of INSN.  */
  
 -- 
 Alan Modra
 IBM OzLabs - Linux Technology Centre


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