================ @@ -3083,6 +3083,19 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( E->getTypeOfArgument()->getPointeeType())) .getQuantity(); return llvm::ConstantInt::get(CGF.SizeTy, Alignment); + } else if (E->getKind() == UETT_VectorElements) { + // For scalable vectors, we don't know the size at compile time. We can use + // @llvm.vscale to calculate it at runtime. + if (E->getTypeOfArgument()->isSizelessVectorType()) { + auto *VecTy = dyn_cast<llvm::ScalableVectorType>( + ConvertType(E->getTypeOfArgument())); + uint64_t NumUnscaledElements = VecTy->getMinNumElements(); + + llvm::Value *VScale = + Builder.CreateVScale(llvm::ConstantInt::get(CGF.SizeTy, 1)); + return Builder.CreateMul( + VScale, llvm::ConstantInt::get(CGF.SizeTy, NumUnscaledElements)); ---------------- lawben wrote:
Neat, thanks for the pointer. that is a lot nicer. @erichkeane this should fix the comments above, as we now handle both types of vectors here and the code is more clear. https://github.com/llvm/llvm-project/pull/69010 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits