https://gcc.gnu.org/g:aa8811570ccb4fde743f56d9fee57dc74972f09a

commit r16-7107-gaa8811570ccb4fde743f56d9fee57dc74972f09a
Author: Andre Vieira <[email protected]>
Date:   Wed Jan 28 11:11:14 2026 +0000

    vect: reconstruct vectype for non scalar masks
    
    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:
    
            PR target/123016
            * 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.

Diff:
---
 gcc/testsuite/gfortran.dg/vect/pr123016.f90 | 22 ++++++++++++++++++++++
 gcc/tree-vect-stmts.cc                      |  9 +++++++++
 2 files changed, 31 insertions(+)

diff --git a/gcc/testsuite/gfortran.dg/vect/pr123016.f90 
b/gcc/testsuite/gfortran.dg/vect/pr123016.f90
new file mode 100644
index 000000000000..1288352f339d
--- /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 15697c024bd8..ba2e46332581 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -4500,6 +4500,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);

Reply via email to