================
@@ -8058,7 +8057,14 @@ bool Sema::CheckVectorCast(SourceRange R, QualType 
VectorTy, QualType Ty,
 }
 
 ExprResult Sema::prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr) {
-  QualType DestElemTy = VectorTy->castAs<VectorType>()->getElementType();
+  QualType DestElemTy =
+      VectorTy->isSizelessVectorType()
+          ? VectorTy->isSveVLSBuiltinType() || VectorTy->isRVVVLSBuiltinType()
+                ? Context
+                      
.getBuiltinVectorTypeInfo(VectorTy->castAs<BuiltinType>())
+                      .ElementType
+                : VectorTy->getSizelessVectorEltType(Context)
+          : VectorTy->castAs<VectorType>()->getElementType();
----------------
MacDue wrote:

This would be much easier to read as a helper like:

```c++
static QualType getVectorElementType(ASTContext &Context, QualType VecTy) {
  if (const auto *TyA = VecTy->getAs<VectorType>())
    return TyA->getElementType();
  if (VecTy->isSizelessVectorType())
    return VecTy->getSizelessVectorEltType(Context);
  return QualType();
}
```

(which already exists in SemaChecking, so maybe factor this to some common 
code). Also, getSizelessVectorEltType looks like it already handles SVE and RVV 
builtins (so does not need additional handling here). 

https://github.com/llvm/llvm-project/pull/205432
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to