[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
Tue Oct 17 06:48:50 PDT 2023


================
@@ -3083,6 +3083,10 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
                 E->getTypeOfArgument()->getPointeeType()))
             .getQuantity();
     return llvm::ConstantInt::get(CGF.SizeTy, Alignment);
+  } else if (E->getKind() == UETT_VectorElements) {
+    auto *VecTy =
+        dyn_cast<llvm::VectorType>(ConvertType(E->getTypeOfArgument()));
----------------
erichkeane wrote:

```suggestion
        cast<llvm::VectorType>(ConvertType(E->getTypeOfArgument()));
```
You immediately dereference this anyway, and I think the semantics guarantees this is the case, correct?

https://github.com/llvm/llvm-project/pull/69010


More information about the libc-commits mailing list