aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-14 14:45:49 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-11-14 14:45:49 +0000
commit0a0ef2387cc1561d537d8d949aef9479ef17ba35 (patch)
tree9c5d882c792520fd488d9020641474564b6e62de /gcc/tree.c
parentd083ee47a9828236016841356fc7207e7c90bbbd (diff)
downloadgcc-0a0ef2387cc1561d537d8d949aef9479ef17ba35.zip
gcc-0a0ef2387cc1561d537d8d949aef9479ef17ba35.tar.gz
gcc-0a0ef2387cc1561d537d8d949aef9479ef17ba35.tar.bz2
Add build_truth_vector_type_for_mode
Callers of vect_halve_mask_nunits and vect_double_mask_nunits already know what mode the resulting vector type should have, so we might as well create the vector type directly with that mode, just like build_vector_type_for_mode lets us build normal vectors with a known mode. This avoids the current awkwardness of having to recompute the mode starting from vec_info::vector_size, which hard-codes the assumption that all vectors have to be the same size. A later patch gets rid of build_truth_vector_type and build_same_sized_truth_vector_type, so the net effect of the series is to reduce the number of type functions by one. 2019-11-14 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree.h (build_truth_vector_type_for_mode): Declare. * tree.c (build_truth_vector_type_for_mode): New function, split out from... (build_truth_vector_type): ...here. (build_opaque_vector_type): Fix head comment. * tree-vectorizer.h (supportable_narrowing_operation): Remove vec_info parameter. (vect_halve_mask_nunits): Replace vec_info parameter with the mode of the new vector. (vect_double_mask_nunits): Likewise. * tree-vect-loop.c (vect_halve_mask_nunits): Likewise. (vect_double_mask_nunits): Likewise. * tree-vect-loop-manip.c: Include insn-config.h, rtl.h and recog.h. (vect_maybe_permute_loop_masks): Remove vinfo parameter. Update call to vect_halve_mask_nunits, getting the required mode from the unpack patterns. (vect_set_loop_condition_masked): Update call accordingly. * tree-vect-stmts.c (supportable_narrowing_operation): Remove vec_info parameter and update call to vect_double_mask_nunits. (vectorizable_conversion): Update call accordingly. (simple_integer_narrowing): Likewise. Remove vec_info parameter. (vectorizable_call): Update call accordingly. (supportable_widening_operation): Update call to vect_halve_mask_nunits. * config/aarch64/aarch64-sve-builtins.cc (register_builtin_types): Use build_truth_vector_type_mode instead of build_truth_vector_type. From-SVN: r278231
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 78c2815..2375bf8 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10873,25 +10873,35 @@ build_vector_type (tree innertype, poly_int64 nunits)
return make_vector_type (innertype, nunits, VOIDmode);
}
+/* Build a truth vector with NUNITS units, giving it mode MASK_MODE. */
+
+tree
+build_truth_vector_type_for_mode (poly_uint64 nunits, machine_mode mask_mode)
+{
+ gcc_assert (mask_mode != BLKmode);
+
+ poly_uint64 vsize = GET_MODE_BITSIZE (mask_mode);
+ unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
+ tree bool_type = build_nonstandard_boolean_type (esize);
+
+ return make_vector_type (bool_type, nunits, mask_mode);
+}
+
/* Build truth vector with specified length and number of units. */
tree
build_truth_vector_type (poly_uint64 nunits, poly_uint64 vector_size)
{
- machine_mode mask_mode
- = targetm.vectorize.get_mask_mode (nunits, vector_size).else_blk ();
-
- poly_uint64 vsize;
- if (mask_mode == BLKmode)
- vsize = vector_size * BITS_PER_UNIT;
- else
- vsize = GET_MODE_BITSIZE (mask_mode);
+ machine_mode mask_mode;
+ if (targetm.vectorize.get_mask_mode (nunits,
+ vector_size).exists (&mask_mode))
+ return build_truth_vector_type_for_mode (nunits, mask_mode);
+ poly_uint64 vsize = vector_size * BITS_PER_UNIT;
unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
-
tree bool_type = build_nonstandard_boolean_type (esize);
- return make_vector_type (bool_type, nunits, mask_mode);
+ return make_vector_type (bool_type, nunits, BLKmode);
}
/* Returns a vector type corresponding to a comparison of VECTYPE. */
@@ -10910,7 +10920,8 @@ build_same_sized_truth_vector_type (tree vectype)
return build_truth_vector_type (TYPE_VECTOR_SUBPARTS (vectype), size);
}
-/* Similarly, but builds a variant type with TYPE_VECTOR_OPAQUE set. */
+/* Like build_vector_type, but builds a variant type with TYPE_VECTOR_OPAQUE
+ set. */
tree
build_opaque_vector_type (tree innertype, poly_int64 nunits)