[clang] [llvm] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector extraction intrinsics to be used in constexpr #157712 (PR #158853)
Timm Baeder via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 21:46:33 PDT 2025
================
@@ -712,6 +712,36 @@ static bool interp__builtin_expect(InterpState &S, CodePtr OpPC,
return true;
}
+
+/// rotateleft(value, amount)
+static bool interp__builtin_rotate(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const CallExpr *Call, bool Right) {
+ APSInt Amount = popToAPSInt(S, Call->getArg(1));
+ APSInt Value = popToAPSInt(S, Call->getArg(0));
+
+ APSInt Result;
+ if (Right)
+ Result = APSInt(Value.rotr(Amount.urem(Value.getBitWidth())),
+ /*IsUnsigned=*/true);
+ else // Left.
+ Result = APSInt(Value.rotl(Amount.urem(Value.getBitWidth())),
+ /*IsUnsigned=*/true);
+
+ pushInteger(S, Result, Call->getType());
+ return true;
+}
+
+static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const CallExpr *Call) {
+ APSInt Value = popToAPSInt(S, Call->getArg(0));
+
+ uint64_t N = Value.countr_zero();
+ pushInteger(S, N == Value.getBitWidth() ? 0 : N + 1, Call->getType());
+ return true;
+}
+
----------------
tbaederr wrote:
Those two functions were removed upstream.
https://github.com/llvm/llvm-project/pull/158853
More information about the llvm-commits
mailing list