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: optimization/6233: simple loop miscompilation


This patch cures PR6233.

gcc/ChangeLog
	* alias.c (nonlocal_referenced_p): Make global.
	* tree.h (nonlocal_referenced_p): Declare.
	* loop.c (prescan_loop): Set has_nonconst_call for pure functions.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: gcc/alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.169
diff -u -p -r1.169 alias.c
--- gcc/alias.c	4 Apr 2002 22:48:16 -0000	1.169
+++ gcc/alias.c	9 Apr 2002 10:55:06 -0000
@@ -112,7 +112,6 @@ static int write_dependence_p           
 static int nonlocal_mentioned_p_1       PARAMS ((rtx *, void *));
 static int nonlocal_mentioned_p         PARAMS ((rtx));
 static int nonlocal_referenced_p_1      PARAMS ((rtx *, void *));
-static int nonlocal_referenced_p        PARAMS ((rtx));
 static int nonlocal_set_p_1             PARAMS ((rtx *, void *));
 static int nonlocal_set_p               PARAMS ((rtx));
 
@@ -2455,7 +2454,7 @@ nonlocal_referenced_p_1 (loc, data)
 /* Returns non-zero if X might reference something which is not
    local to the function and is not constant.  */
 
-static int
+int
 nonlocal_referenced_p (x)
      rtx x;
 {
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	9 Apr 2002 10:55:27 -0000
@@ -2493,6 +2493,8 @@ prescan_loop (loop)
 	      loop_info->unknown_address_altered = 1;
 	      loop_info->has_nonconst_call = 1;
 	    }
+	  else if (nonlocal_referenced_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/tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.327
diff -u -p -r1.327 tree.h
--- gcc/tree.h	4 Apr 2002 22:19:38 -0000	1.327
+++ gcc/tree.h	9 Apr 2002 10:55:30 -0000
@@ -2815,6 +2815,7 @@ extern int alias_sets_conflict_p		PARAMS
 							 HOST_WIDE_INT));
 extern int readonly_fields_p			PARAMS ((tree));
 extern int objects_must_conflict_p		PARAMS ((tree, tree));
+extern int nonlocal_referenced_p		PARAMS ((rtx));
 
 struct obstack;
 


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