[libc-commits] [libc] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)
Erich Keane via libc-commits
libc-commits at lists.llvm.org
Mon Oct 16 09:22:47 PDT 2023
================
@@ -13595,6 +13595,15 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
Info.Ctx.getOpenMPDefaultSimdAlign(E->getArgumentType()))
.getQuantity(),
E);
+ case UETT_VectorElements: {
+ QualType Ty = E->getTypeOfArgument();
+ // If the vector has a fixed size, we can determine the number of elements
+ // at compile time.
+ if (Ty->isVectorType())
+ return Success(Ty->castAs<VectorType>()->getNumElements(), E);
+
+ return false;
----------------
erichkeane wrote:
Your understanding of how this works is correct, I missed you were handling sizeless vectors that way. So above 'return false' there
could be an `assert(Ty->isSizelessVectorType())` ?
Note that we're not guaranteed to come to ExprConstant.cpp in the case where it is a sized-vector, so you likely need to make sure the CGExprScalar code handles sized types as well.
https://github.com/llvm/llvm-project/pull/69010
More information about the libc-commits
mailing list