https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97521
--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> --- Maybe the x86 backend should use partial integer modes here (though we'd have quite some, eventually not even possible), so the mask mode precision would tell us how to build the types. Or the targetm.vectorize.get_mask_mode needs to be amended to return the number of bits used per lane. So the following "works" for the testcase in this bug and the FAILs reported but of course breaks the non-AVX512 case because we cannot distinguish between integer mode vectors and integer mode masks :/ The target hook docs leave the option to return no mask mode but the default implementation would already always return an integer vector mode if it exists. So given that changing x86 to use MODE_VECTOR_BOOL is unlikely we need a way to distinguish MODE_INT vectors from MODE_INT vector bools, thus, the target needs to tell us the precision of the elements. diff --git a/gcc/expr.c b/gcc/expr.c index 9d951e82522..ae16f077758 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -10356,16 +10355,10 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, scalar_int_mode int_mode; if (is_int_mode (mode, &int_mode)) { - if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))) - return const_scalar_mask_from_tree (int_mode, exp); - else - { - tree type_for_mode - = lang_hooks.types.type_for_mode (int_mode, 1); - if (type_for_mode) - tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR, - type_for_mode, exp); - } + tree type_for_mode = lang_hooks.types.type_for_mode (int_mode, 1); + if (type_for_mode) + tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR, + type_for_mode, exp); } if (!tmp) { diff --git a/gcc/tree.c b/gcc/tree.c index 555ba97e68b..6eeee08f124 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -10926,9 +10926,7 @@ 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); + tree bool_type = build_nonstandard_boolean_type (1); return make_vector_type (bool_type, nunits, mask_mode); }