]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: reconstruct vectype for non scalar masks
authorAndre Vieira <andre.simoesdiasvieira@arm.com>
Wed, 28 Jan 2026 11:11:14 +0000 (11:11 +0000)
committerAndre Vieira <andre.simoesdiasvieira@arm.com>
Wed, 28 Jan 2026 11:13:44 +0000 (11:13 +0000)
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.

gcc/testsuite/gfortran.dg/vect/pr123016.f90 [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gfortran.dg/vect/pr123016.f90 b/gcc/testsuite/gfortran.dg/vect/pr123016.f90
new file mode 100644 (file)
index 0000000..1288352
--- /dev/null
@@ -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
index 15697c024bd8d5050a041e5aa350a3726e17ab0a..ba2e463325818d87c7146915874e30af61732500 100644 (file)
@@ -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);