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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2025-12-05
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org
           Priority|P3                          |P1
   Target Milestone|---                         |16.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed with a cross.  The issue is similar to that originally observed
elsewhere.  We have incompatible vector([4,4]) <signed-boolean:4> and
vector([4,4]) <signed-boolean:4>, due to 'SVE type' attribute on one.

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3787e7bdfb6..f2945fe99ff 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -59,6 +59,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "case-cfn-macros.h"
 #include "langhooks.h"
 #include "opts.h"
+#include "attribs.h"

 /* Loop Vectorization Pass.

@@ -10457,7 +10458,7 @@ void
 vect_record_loop_mask (loop_vec_info loop_vinfo, vec_loop_masks *masks,
                       unsigned int nvectors, tree vectype, tree scalar_mask)
 {
-  gcc_assert (nvectors != 0);
+  gcc_assert (nvectors != 0 && !lookup_attribute ("SVE type", TYPE_ATTRIBUTES
(vectype)));

   if (scalar_mask)
     {

shows who registers such type:

internal compiler error: in vect_record_loop_mask, at tree-vect-loop.cc:10461
0x3908f33 internal_error(char const*, ...)
        /home/rguenther/src/gcc/gcc/diagnostic-global-context.cc:787
0x3919482 fancy_abort(char const*, int, char const*)
        /home/rguenther/src/gcc/gcc/diagnostics/context.cc:1805
0x1f713b1 vect_record_loop_mask(_loop_vec_info*, vec_loop_masks*, unsigned int,
tree_node*, tree_node*)
        /home/rguenther/src/gcc/gcc/tree-vect-loop.cc:10461
0x1f1c000 vectorizable_simd_clone_call
        /home/rguenther/src/gcc/gcc/tree-vect-stmts.cc:4452


                      masktype =
bestn_inbranch->simdclone->args[i].vector_type;
                      callee_nelements = TYPE_VECTOR_SUBPARTS (masktype);
                    }
                  auto o = vector_unroll_factor (nunits, callee_nelements);
                  vect_record_loop_mask (loop_vinfo,
                                         &LOOP_VINFO_MASKS (loop_vinfo),
                                         ncopies  * o, masktype, NULL_TREE);

SVE has restrictions on ncopies and o here that made simply passing
'vectype' (which is based on the scalar code call) "correct".  The x86
code does

                  if (SCALAR_INT_MODE_P (bestn_inbranch->simdclone->mask_mode))
                    {
                      callee_nelements
                          = exact_div (bestn_inbranch->simdclone->simdlen,
                                      
bestn_inbranch->simdclone->args[i].linear_step);
                      masktype = get_related_vectype_for_scalar_type
                          (vinfo->vector_mode, TREE_TYPE (vectype),
                           callee_nelements);

so we pass vect_record_loop_mask a data type with the appropriate number
of expected elements for the simd clone call.  For SVE you could do
sth similar depending on how to construct the data vector correspondig
to the SIMD call mask argument.  IIRC the mask for a V4DF is not the same
as the mask for a V4SI?

I'll leave this to arm folks to sort out, but while vect_record_loop_mask
is in theory fine with recording a bool vector (we don't assert it isn't),
a SVE vector built-in will cause issues as can be seen here and the SIMD
clone info has those "API types".

Reply via email to