optimization/6233: simple loop miscompilation

Alan Modra amodra@bigpond.net.au
Tue Apr 9 20:57:00 GMT 2002


On Tue, Apr 09, 2002 at 07:03:42PM -0700, Richard Henderson wrote:
> On Wed, Apr 10, 2002 at 10:32:37AM +0930, Alan Modra wrote:
> > 	* rtlanal.c (pure_call_p): New function.
> > 	* rtl.h (pure_call_p): Declare.
> > 	* loop.c (prescan_loop): Use it to set has_nonconst_call.
> 
> Much better, thanks.
> 
> For mainline, would you change store_killed_in_insn
> to use this too, please?

Committed.  Extras from the last patch I posted:

gcc/ChangeLog
	* gcse.c (store_killed_in_insn): Use pure_call_p here too.

gcc/testsuite/ChangeLog
	* gcc.c-torture/execute/loop-12.c: New.

Index: gcc/gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.182
diff -u -p -r1.182 gcse.c
--- gcc/gcse.c	9 Apr 2002 21:15:38 -0000	1.182
+++ gcc/gcse.c	10 Apr 2002 02:38:20 -0000
@@ -6528,21 +6528,7 @@ store_killed_in_insn (x, insn)
     {
       /* A normal or pure call might read from pattern,
 	 but a const call will not.  */
-      if (CONST_OR_PURE_CALL_P (insn))
-	{
-	  rtx link;
-
-	  for (link = CALL_INSN_FUNCTION_USAGE (insn);
-	       link;
-	       link = XEXP (link, 1))
-	    if (GET_CODE (XEXP (link, 0)) == USE
-		&& GET_CODE (XEXP (XEXP (link, 0), 0)) == MEM
-		&& GET_CODE (XEXP (XEXP (XEXP (link, 0), 0), 0)) == SCRATCH)
-	      return 1;
-	  return 0;
-	}
-      else
-	return 1;
+      return ! CONST_OR_PURE_CALL_P (insn) || pure_call_p (insn);
     }
   
   if (GET_CODE (PATTERN (insn)) == SET)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Gcc-patches mailing list