* [s390] RFA: Use new rtl iterators in s390_loop_unroll_adjust
@ 2014-10-25 10:13 Richard Sandiford
2014-10-27 8:51 ` Andreas Krebbel
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2014-10-25 10:13 UTC (permalink / raw)
To: gcc-patches; +Cc: uweigand, Andreas.Krebbel
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?
Thanks,
Richard
gcc/
* config/s390/s390.c: Include rtl-iter.h.
(check_dpu): Delete.
(s390_loop_unroll_adjust): Only iterate over patterns.
Use FOR_EACH_SUBRTX.
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. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [s390] RFA: Use new rtl iterators in s390_loop_unroll_adjust
2014-10-25 10:13 [s390] RFA: Use new rtl iterators in s390_loop_unroll_adjust Richard Sandiford
@ 2014-10-27 8:51 ` Andreas Krebbel
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Krebbel @ 2014-10-27 8:51 UTC (permalink / raw)
To: gcc-patches, uweigand, Andreas.Krebbel, rdsandiford
On 10/25/2014 12:10 PM, Richard Sandiford wrote:
> 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?
Ok. Thanks!
-Andreas-
>
> Thanks,
> Richard
>
>
> gcc/
> * config/s390/s390.c: Include rtl-iter.h.
> (check_dpu): Delete.
> (s390_loop_unroll_adjust): Only iterate over patterns.
> Use FOR_EACH_SUBRTX.
>
> 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. */
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-27 8:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-25 10:13 [s390] RFA: Use new rtl iterators in s390_loop_unroll_adjust Richard Sandiford
2014-10-27 8:51 ` Andreas Krebbel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).