This is the mail archive of the 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]

[s390] RFA: Use new rtl iterators in s390_loop_unroll_adjust

This is part of a series to remove uses of for_each_rtx from the ports.
I think we only want to consider MEMs in patterns here, not MEMs in notes etc.
(Not sure why I "fixed" it for s390 but not for x86...)

Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
and g++.dg for s390x-linux-gnu.  OK to install?


	* config/s390/s390.c: Include rtl-iter.h.
	(check_dpu): Delete.
	(s390_loop_unroll_adjust): Only iterate over patterns.

Index: gcc/config/s390/s390.c
--- gcc/config/s390/s390.c	2014-10-25 09:40:37.948516349 +0100
+++ gcc/config/s390/s390.c	2014-10-25 09:51:28.229908359 +0100
@@ -74,6 +74,7 @@ Software Foundation; either version 3, o
 #include "tree-pass.h"
 #include "context.h"
 #include "builtins.h"
+#include "rtl-iter.h"
 /* Define the specific costs for a given cpu.  */
@@ -11749,19 +11750,6 @@ s390_sched_init (FILE *file ATTRIBUTE_UN
   s390_sched_state = 0;
-/* This function checks the whole of insn X for memory references. The
-   function always returns zero because the framework it is called
-   from would stop recursively analyzing the insn upon a return value
-   other than zero. The real result of this function is updating
-   counter variable MEM_COUNT.  */
-static int
-check_dpu (rtx *x, unsigned *mem_count)
-  if (*x != NULL_RTX && MEM_P (*x))
-    (*mem_count)++;
-  return 0;
 /* This target hook implementation for TARGET_LOOP_UNROLL_ADJUST calculates
    a new number struct loop *loop should be unrolled if tuned for cpus with
    a built-in stride prefetcher.
@@ -11784,12 +11772,13 @@ s390_loop_unroll_adjust (unsigned nunrol
   /* Count the number of memory references within the loop body.  */
   bbs = get_loop_body (loop);
+  subrtx_iterator::array_type array;
   for (i = 0; i < loop->num_nodes; i++)
-    {
-      for (insn = BB_HEAD (bbs[i]); insn != BB_END (bbs[i]); insn = NEXT_INSN (insn))
-	if (INSN_P (insn) && INSN_CODE (insn) != -1)
-            for_each_rtx_in_insn (&insn, (rtx_function) check_dpu, &mem_count);
-    }
+    FOR_BB_INSNS (bbs[i], insn)
+      if (INSN_P (insn) && INSN_CODE (insn) != -1)
+	FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST)
+	  if (MEM_P (*iter))
+	    mem_count += 1;
   free (bbs);
   /* Prevent division by zero, and we do not need to adjust nunroll in this case.  */

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