From f09552335030433018fd5f7f6b9848339b5ca2da Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 14 Nov 2019 14:36:26 +0000 Subject: 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 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 --- gcc/machmode.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/machmode.h') diff --git a/gcc/machmode.h b/gcc/machmode.h index 64ac213..906b216 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -880,6 +880,8 @@ extern opt_scalar_int_mode int_mode_for_mode (machine_mode); extern opt_machine_mode bitwise_mode_for_mode (machine_mode); extern opt_machine_mode mode_for_vector (scalar_mode, poly_uint64); extern opt_machine_mode mode_for_int_vector (unsigned int, poly_uint64); +extern opt_machine_mode related_vector_mode (machine_mode, scalar_mode, + poly_uint64 = 0); /* Return the integer vector equivalent of MODE, if one exists. In other words, return the mode for an integer vector that has the same number -- cgit v1.1