This reconstructs the masks vectype based on the the type set by the backend
for any non scalar masks, which resolves the ICE caused by the sve type
attribute in SVE types used for simdclones.
gcc/ChangeLog:
* tree-vect-stmts.cc (vectorizable_simd_clone_call): use
'build_truth_vector_type_for_mode' to reconstruct mask's vectype for
non-scalar masks.
gcc/testsuite/ChangeLog:
* gfortran.dg/vect/pr123016.f90: New test.
Ok for trunk?
On 22/01/2026 15:27, Andre Vieira wrote:
On 22/01/2026 09:36, Richard Biener wrote:
On Wed, Jan 21, 2026 at 5:29 PM Andre Vieira
<[email protected]> wrote:
Hi,
This uses 'get_related_vectype_for_scalar_type' to construct a
standard vectype
for any non scalar masks, which resolves the ICE caused by the sve type
attribute in SVE types used for simdclones.
Tested on aarch64-none-linux-gnu. OK for trunk?
So we're essentially re-building the simdclone masktype to avoid the
ICE. And
we want exactly the same vector type. IMO
masktype = build_truth_vector_type_for_mode (TYPE_VECTOR_SUBPARTS
(masktype), TYPE_MODE (masktype));
would achieve this in a more obvious way?
Actually that does preserve the vector mode whereas related does not,
related used to generate VNx4QI for the testcase, whereas the original
mode was VNx4BI. So your approach is probably better, I don't think it
matters much in the end because both get dealt with the same by
VEC_COND_EXPR which is how it 'converts' the loop mask into the
parameter and it all ends up as NOPs in the examples I looked at, but
yeah... I'll just go run all the tests with this one and see if
anything falls out, but I suspect it'll be fine too.
Thx!
PR target/123016
gcc/ChangeLog:
* tree-vect-stmts.cc (vectorizable_simd_clone_call): use
get_related_vectype_for_scalar_type to reconstruct standard
vectype for
non-scalar masks.
gcc/testsuite/ChangeLog:
* gfortran.dg/vect/pr123016.f90: New test.
diff --git a/gcc/testsuite/gfortran.dg/vect/pr123016.f90
b/gcc/testsuite/gfortran.dg/vect/pr123016.f90
new file mode 100644
index
0000000000000000000000000000000000000000..1288352f339d86c45a604eadfdb88c5deb75b170
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/pr123016.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-additional-options "-Ofast" }
+! { dg-additional-options "-mcpu=neoverse-v2" { target aarch64*-*-* } }"
+!GCC$ builtin (expf) attributes simd (notinbranch)
+ MODULE MODULE_CU_BMJ
+ INTEGER:: JTB
+ CONTAINS
+ SUBROUTINE BMJDRVRQVCUTEN
+REAL, DIMENSION(JTB) :: THEOLD,TOLDY2T
+ DO KTH=1,KTHM
+ TH=TH+DTH
+ DENOM=TH
+ IF (DENOM>EPS) THEN
+ QS=EXP(0/DENOM)
+ ELSE
+ QS=0.
+ ENDIF
+ THEOLD(KTH)=EXP(ELOCP*QS)
+ ENDDO
+ CALL SPLINE
+ END
+ END
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index
ee98e72d1e574eb8c7e86f271c105b16272e3a28..c39a29bb736777f406c3b8203bfef4f43440cac8
100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -4484,6 +4484,15 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
else
{
masktype = bestn_inbranch->simdclone->args[i].vector_type;
+ /* The aarch64 port will add custom attributes to types
+ for SVE simdclones which make the types different. We
+ should use canonincal types for masks within the
+ vectorizer, hence we construct the related vectype
+ here. */
+ masktype
+ = build_truth_vector_type_for_mode
+ (TYPE_VECTOR_SUBPARTS (masktype),
+ TYPE_MODE (masktype));
callee_nelements = TYPE_VECTOR_SUBPARTS (masktype);
}
auto o = vector_unroll_factor (nunits, callee_nelements);