diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-11-14 14:39:57 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-11-14 14:39:57 +0000 |
commit | d083ee47a9828236016841356fc7207e7c90bbbd (patch) | |
tree | 90747a64f3a7312d7fcdd25bc7c864ff408c02df /gcc/stor-layout.c | |
parent | f09552335030433018fd5f7f6b9848339b5ca2da (diff) | |
download | gcc-d083ee47a9828236016841356fc7207e7c90bbbd.zip gcc-d083ee47a9828236016841356fc7207e7c90bbbd.tar.gz gcc-d083ee47a9828236016841356fc7207e7c90bbbd.tar.bz2 |
Replace mode_for_int_vector with related_int_vector_mode
mode_for_int_vector, like mode_for_vector, can sometimes return
an integer mode or an unsupported vector mode. But no callers
are interested in that case, and only want supported vector modes.
This patch therefore replaces mode_for_int_vector with
related_int_vector_mode, which gives the target a chance to pick
its preferred vector mode for the given element mode and size.
2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* machmode.h (mode_for_int_vector): Delete.
(related_int_vector_mode): Declare.
* stor-layout.c (mode_for_int_vector): Delete.
(related_int_vector_mode): New function.
* optabs.c (expand_vec_perm_1): Use related_int_vector_mode
instead of mode_for_int_vector.
(expand_vec_perm_const): Likewise.
* config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Likewise.
(aarch64_evpc_sve_tbl): Likewise.
* config/s390/s390.c (s390_expand_vec_compare_cc): Likewise.
(s390_expand_vcond): Likewise.
From-SVN: r278230
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index c1b724f..7d00364 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -515,21 +515,6 @@ mode_for_vector (scalar_mode innermode, poly_uint64 nunits) return opt_machine_mode (); } -/* Return the mode for a vector that has NUNITS integer elements of - INT_BITS bits each, if such a mode exists. The mode can be either - an integer mode or a vector mode. */ - -opt_machine_mode -mode_for_int_vector (unsigned int int_bits, poly_uint64 nunits) -{ - scalar_int_mode int_mode; - machine_mode vec_mode; - if (int_mode_for_size (int_bits, 0).exists (&int_mode) - && mode_for_vector (int_mode, nunits).exists (&vec_mode)) - return vec_mode; - return opt_machine_mode (); -} - /* If a piece of code is using vector mode VECTOR_MODE and also wants to operate on elements of mode ELEMENT_MODE, return the vector mode it should use for those elements. If NUNITS is nonzero, ensure that @@ -550,6 +535,26 @@ related_vector_mode (machine_mode vector_mode, scalar_mode element_mode, return targetm.vectorize.related_mode (vector_mode, element_mode, nunits); } +/* If a piece of code is using vector mode VECTOR_MODE and also wants + to operate on integer vectors with the same element size and number + of elements, return the vector mode it should use. Return an empty + opt_machine_mode if there is no supported vector mode with the + required properties. + + Unlike mode_for_vector. any returned mode is guaranteed to satisfy + both VECTOR_MODE_P and targetm.vector_mode_supported_p. */ + +opt_machine_mode +related_int_vector_mode (machine_mode vector_mode) +{ + gcc_assert (VECTOR_MODE_P (vector_mode)); + scalar_int_mode int_mode; + if (int_mode_for_mode (GET_MODE_INNER (vector_mode)).exists (&int_mode)) + return related_vector_mode (vector_mode, int_mode, + GET_MODE_NUNITS (vector_mode)); + return opt_machine_mode (); +} + /* Return the alignment of MODE. This will be bounded by 1 and BIGGEST_ALIGNMENT. */ |