summaryrefslogtreecommitdiff
path: root/gcc/targhooks.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-14 14:36:26 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-11-14 14:36:26 +0000
commitf09552335030433018fd5f7f6b9848339b5ca2da (patch)
tree78e267da95a352d5303bc66b513ab10e2f5979a9 /gcc/targhooks.c
parent89cd5050928afa2d2e9cf836ae39f6cb947f5602 (diff)
Add a targetm.vectorize.related_mode hook
This patch is the first of a series that tries to remove two assumptions: (1) that all vectors involved in vectorisation must be the same size (2) that there is only one vector mode for a given element mode and number of elements Relaxing (1) helps with targets that support multiple vector sizes or that require the number of elements to stay the same. E.g. if we're vectorising code that operates on narrow and wide elements, and the narrow elements use 64-bit vectors, then on AArch64 it would normally be better to use 128-bit vectors rather than pairs of 64-bit vectors for the wide elements. Relaxing (2) makes it possible for -msve-vector-bits=128 to produce fixed-length code for SVE. It also allows unpacked/half-size SVE vectors to work with -msve-vector-bits=256. The patch adds a new hook that targets can use to control how we move from one vector mode to another. The hook takes a starting vector mode, a new element mode, and (optionally) a new number of elements. The flexibility needed for (1) comes in when the number of elements isn't specified. All callers in this patch specify the number of elements, but a later vectoriser patch doesn't. 2019-11-14 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (related_mode): New hook. * doc/tm.texi.in (TARGET_VECTORIZE_RELATED_MODE): New hook. * doc/tm.texi: Regenerate. * targhooks.h (default_vectorize_related_mode): Declare. * targhooks.c (default_vectorize_related_mode): New function. * machmode.h (related_vector_mode): Declare. * stor-layout.c (related_vector_mode): New function. * expmed.c (extract_bit_field_1): Use it instead of mode_for_vector. * optabs-query.c (qimode_for_vec_perm): Likewise. * tree-vect-stmts.c (get_group_load_store_type): Likewise. (vectorizable_store, vectorizable_load): Likewise From-SVN: r278229
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r--gcc/targhooks.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index b6443d204a6..dcecd81e54d 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -1306,6 +1306,25 @@ default_autovectorize_vector_sizes (vector_sizes *, bool)
{
}
+/* The default implementation of TARGET_VECTORIZE_RELATED_MODE. */
+
+opt_machine_mode
+default_vectorize_related_mode (machine_mode vector_mode,
+ scalar_mode element_mode,
+ poly_uint64 nunits)
+{
+ machine_mode result_mode;
+ if ((maybe_ne (nunits, 0U)
+ || multiple_p (GET_MODE_SIZE (vector_mode),
+ GET_MODE_SIZE (element_mode), &nunits))
+ && mode_for_vector (element_mode, nunits).exists (&result_mode)
+ && VECTOR_MODE_P (result_mode)
+ && targetm.vector_mode_supported_p (result_mode))
+ return result_mode;
+
+ return opt_machine_mode ();
+}
+
/* By default a vector of integers is used as a mask. */
opt_machine_mode