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]

A loop.c patch


Hi,

Here is a loop patch and a testcase. I have reported it earlier with
my analysis.


-- 
H.J. Lu (hjl@gnu.org)
---
Tue Jun 30 18:57:51 1998  H.J. Lu  (hjl@gnu.org)

	* loop.c (note_addr_stored): Record the memory referenced by X
	if its equivalent memory reference is set.

Index: loop.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/gcc/loop.c,v
retrieving revision 1.1.1.30
diff -u -p -r1.1.1.30 loop.c
--- loop.c	1998/06/24 16:42:58	1.1.1.30
+++ loop.c	1998/07/01 02:56:28
@@ -2833,17 +2833,44 @@ labels_in_range_p (insn, end)
   return 0;
 }
 
-/* Record that a memory reference X is being set.  */
+/* Record that a memory reference X in PAT is being set or a memory
+   referenced by X has been set.  */
 
 static void
-note_addr_stored (x, y)
+note_addr_stored (x, pat)
      rtx x;
-     rtx y ATTRIBUTE_UNUSED;
+     rtx pat;
 {
   register int i;
 
-  if (x == 0 || GET_CODE (x) != MEM)
+  if (x == 0)
     return;
+  else if (GET_CODE (x) != MEM)
+    {
+      if (loop_store_mems_idx >= NUM_STORES)
+	return;
+
+      /* We need to check if the memory referenced by SET_SRC (pat) is
+	 set or not before since SET_SRC (pat) may be used to reference
+	 that memory later. */
+      if (GET_CODE (pat) != SET)
+	pat = single_set (pat);
+
+      if (!pat || !rtx_equal_p (SET_DEST (pat), x)
+	  || rtx_equal_p (SET_SRC (pat), x)
+	  || GET_CODE (x) != REG)
+	return;
+
+      for (i = 0; i < loop_store_mems_idx; i++)
+  	if (rtx_equal_p (XEXP (loop_store_mems[i], 0), SET_SRC (pat)))
+	  {
+	    loop_store_mems[loop_store_mems_idx++]
+	      = gen_rtx_MEM (GET_MODE (loop_store_mems[i]), x);
+	    break;
+	  }
+
+      return;
+    }
 
   /* Count number of memory writes.
      This affects heuristics in strength_reduce.  */


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