+2018-05-07 Luis Machado <luis.machado@linaro.org>
+
+ gcc/
+ * config/aarch64/aarch64-protos.h (cpu_prefetch_tune)
+ <prefetch_dynamic_strides>: 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.
+
2018-05-07 Luis Machado <luis.machado@linaro.org>
gcc/
const int l1_cache_size;
const int l1_cache_line_size;
const int l2_cache_size;
+ /* Whether software prefetch hints should be issued for non-constant
+ strides. */
+ const bool prefetch_dynamic_strides;
/* The minimum constant stride beyond which we should use prefetch
hints for. */
const int minimum_stride;
-1, /* l1_cache_size */
-1, /* l1_cache_line_size */
-1, /* l2_cache_size */
+ true, /* prefetch_dynamic_strides */
-1, /* minimum_stride */
-1 /* default_opt_level */
};
-1, /* l1_cache_size */
64, /* l1_cache_line_size */
-1, /* l2_cache_size */
+ true, /* prefetch_dynamic_strides */
-1, /* minimum_stride */
-1 /* default_opt_level */
};
32, /* l1_cache_size */
64, /* l1_cache_line_size */
1024, /* l2_cache_size */
+ false, /* prefetch_dynamic_strides */
2048, /* minimum_stride */
3 /* default_opt_level */
};
32, /* l1_cache_size */
128, /* l1_cache_line_size */
16*1024, /* l2_cache_size */
+ true, /* prefetch_dynamic_strides */
-1, /* minimum_stride */
3 /* default_opt_level */
};
32, /* l1_cache_size */
128, /* l1_cache_line_size */
-1, /* l2_cache_size */
+ true, /* prefetch_dynamic_strides */
-1, /* minimum_stride */
-1 /* default_opt_level */
};
32, /* l1_cache_size */
64, /* l1_cache_line_size */
256, /* l2_cache_size */
+ true, /* prefetch_dynamic_strides */
-1, /* minimum_stride */
-1 /* default_opt_level */
};
aarch64_tune_params.prefetch->l2_cache_size,
opts->x_param_values,
global_options_set.x_param_values);
+ if (!aarch64_tune_params.prefetch->prefetch_dynamic_strides)
+ maybe_set_param_value (PARAM_PREFETCH_DYNAMIC_STRIDES,
+ 0,
+ opts->x_param_values,
+ global_options_set.x_param_values);
if (aarch64_tune_params.prefetch->minimum_stride >= 0)
maybe_set_param_value (PARAM_PREFETCH_MINIMUM_STRIDE,
aarch64_tune_params.prefetch->minimum_stride,
@item l2-cache-size
The size of L2 cache, in kilobytes.
+@item prefetch-dynamic-strides
+Whether the loop array prefetch pass should issue software prefetch hints
+for strides that are non-constant. In some cases this may be
+beneficial, though the fact the stride is non-constant may make it
+hard to predict when there is clear benefit to issuing these hints.
+
+Set to 1, the default, if the prefetch hints should be issued for non-constant
+strides. Set to 0 if prefetch hints should be issued only for strides that
+are known to be constant and below @option{prefetch-minimum-stride}.
+
@item prefetch-minimum-stride
Minimum constant stride, in bytes, to start using prefetch hints for. If
the stride is less than this threshold, prefetch hints will not be issued.
"The size of L2 cache.",
512, 0, 0)
+/* Whether software prefetch hints should be issued for non-constant
+ strides. */
+
+DEFPARAM (PARAM_PREFETCH_DYNAMIC_STRIDES,
+ "prefetch-dynamic-strides",
+ "Whether software prefetch hints should be issued for non-constant "
+ "strides.",
+ 1, 0, 1)
+
/* The minimum constant stride beyond which we should use prefetch hints
for. */
PARAM_VALUE (PARAM_L1_CACHE_LINE_SIZE)
#define L2_CACHE_SIZE \
PARAM_VALUE (PARAM_L2_CACHE_SIZE)
+#define PREFETCH_DYNAMIC_STRIDES \
+ PARAM_VALUE (PARAM_PREFETCH_DYNAMIC_STRIDES)
#define PREFETCH_MINIMUM_STRIDE \
PARAM_VALUE (PARAM_PREFETCH_MINIMUM_STRIDE)
#define USE_CANONICAL_TYPES \
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