================ @@ -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; ---------------- lawben wrote:
maybe my understanding here is wrong, so please correct me in that case. If the vector is fixed-sized, we can determine the number of elements at compile time, which is why we return the number here in `ExprConstant.cpp`. if it is a scalable vector, we `return false`, as we cannot determine a constant value. in that case, we move along and hit `CGExprScalar.cpp`, which is where we emit the runtime `vscale` code for anything that is not constant. So in my understanding, we either emit a constant in `ExprConstant` or the runtime logic in `CGExprScalar`. I can add assertions to check that we are always in a good case, but i've not come across a fixed-sized vector path that does not get caught in `ExprConstant`. if there are alternative code paths, then you are correct and I should add checks. but I don't want to duplicate logic if this case can never happen anyway. 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