From d2ff35c0913539a31782fbc05bb6d4c2ce74f2ce Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Wed, 23 May 2018 16:23:11 +0000 Subject: [Patch 02/02] Introduce prefetch-dynamic-strides option The following patch adds an option to control software prefetching of memory references with non-constant/unknown strides. Currently we prefetch these references if the pass thinks there is benefit to doing so. But, since this is all based on heuristics, it's not always the case that we end up with better performance. For Falkor there is also the problem of conflicts with the hardware prefetcher, so we need to be more conservative in terms of what we issue software prefetch hints for. This also aligns GCC with what LLVM does for Falkor. Similarly to the previous patch, the defaults guarantee no change in behavior for other targets and architectures. gcc/ChangeLog: 2018-05-23 Luis Machado * config/aarch64/aarch64-protos.h (cpu_prefetch_tune) : New const bool field. * config/aarch64/aarch64.c (generic_prefetch_tune): Update to include prefetch_dynamic_strides. (exynosm1_prefetch_tune): Likewise. (thunderxt88_prefetch_tune): Likewise. (thunderx_prefetch_tune): Likewise. (thunderx2t99_prefetch_tune): Likewise. (qdf24xx_prefetch_tune): Likewise. Set prefetch_dynamic_strides to false. (aarch64_override_options_internal): Update to set PARAM_PREFETCH_DYNAMIC_STRIDES. * doc/invoke.texi (prefetch-dynamic-strides): Document new option. * params.def (PARAM_PREFETCH_DYNAMIC_STRIDES): New. * params.h (PARAM_PREFETCH_DYNAMIC_STRIDES): Define. * tree-ssa-loop-prefetch.c (should_issue_prefetch_p): Account for prefetch-dynamic-strides setting. From-SVN: r260618 --- gcc/tree-ssa-loop-prefetch.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/tree-ssa-loop-prefetch.c') diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c index ac89bf76a6a..c3e7fd1e529 100644 --- a/gcc/tree-ssa-loop-prefetch.c +++ b/gcc/tree-ssa-loop-prefetch.c @@ -992,6 +992,16 @@ prune_by_reuse (struct mem_ref_group *groups) static bool should_issue_prefetch_p (struct mem_ref *ref) { + /* Do we want to issue prefetches for non-constant strides? */ + if (!cst_and_fits_in_hwi (ref->group->step) && PREFETCH_DYNAMIC_STRIDES == 0) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + "Skipping non-constant step for reference %u:%u\n", + ref->group->uid, ref->uid); + return false; + } + /* Some processors may have a hardware prefetcher that may conflict with prefetch hints for a range of strides. Make sure we don't issue prefetches for such cases if the stride is within this particular -- cgit v1.2.3