[clang] [clang] constexpr built-in elementwise popcount function. (PR #117473)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 06:52:33 PST 2024


================
@@ -11302,6 +11303,35 @@ static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO,
   return false;
 }
 
+bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
+  if (!IsConstantEvaluatedBuiltinCall(E))
+    return ExprEvaluatorBaseTy::VisitCallExpr(E);
+
+  switch (E->getBuiltinCallee()) {
+  default:
+    return false;
+  case Builtin::BI__builtin_elementwise_popcount: {
+    APValue Source;
+    if (!EvaluateAsRValue(Info, E->getArg(0), Source))
+      return false;
+
+    QualType DestTy = E->getType()->castAs<VectorType>()->getElementType();
----------------
c8ef wrote:

Done.

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


More information about the cfe-commits mailing list