https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97521

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> And we do that because:
>     case VECTOR_CST:
>       {
>         tree tmp = NULL_TREE;
>         if (VECTOR_MODE_P (mode))
>           return const_vector_from_tree (exp);
>         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);

I think const_scalar_mask_from_tree is completely wrong in ignoring the
precision of the VECTOR_BOOLEAN component type.  At least it is
inconsistent with the processing of VECTOR_BOOLEAN_TYPE_P CTORs.

Now I can see that this was intended for AVX512 but I can't see how this
"inconsistency" can possibly work if you consider the use of _1:

  _19 = BIT_FIELD_REF <_1, 64, 0>;

if you disable TER then how should we ever able to "reinterpret" the
BIT_FIELD_REF to the "narrowed" view of the VECTOR_BOOLEAN_TYPE_P
mask?

A heuristic for an intermediate hack might be to skip
const_scalar_mask_from_tree when the component precision times the
number of elements equals the mode precision of the vector.

Thus the following fixes the testcase

diff --git a/gcc/expr.c b/gcc/expr.c
index 9d951e82522..d87bda777d0 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -10356,7 +10356,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)))
+           if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))
+               && maybe_ne (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (exp)))
+                            * TYPE_VECTOR_SUBPARTS (TREE_TYPE (exp)),
+                            GET_MODE_PRECISION (int_mode)))
              return const_scalar_mask_from_tree (int_mode, exp);
            else

but I have no easy access to a AVX512 runtime system (and no idea how to
make dejagnu use sde for a i386.exp testsuite run).  On a AVX2 system
i386.exp is clean with the above.

Thoughts?

[AVX512 should have used VnBImode like SVE does]

> where the VECTOR_CST type is now a vector boolean with DImode element type
> and TImode as the (poor man's) vector mode.
> 
> So, the question is how to differentiate between vector booleans that want
> to be a bitmask in an integral mode vs. poor man's vector booleans for which
> we'd want to fallthru into the VIEW_CONVERT_EXPR code below this.
> And what other spots need that.
> Perhaps check if the bitsize (or precision?) of the vector type's mode is
> equal to bitsize (or precision?) of the element mode times number of
> elements in the vector?

Reply via email to