[clang] [clang] Implement constexpr support for __builtin_{clzg, ctzg} (PR #86577)
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 25 16:21:41 PDT 2024
================
@@ -12367,8 +12368,17 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
BuiltinOp != Builtin::BI__lzcnt &&
BuiltinOp != Builtin::BI__lzcnt64;
- if (ZeroIsUndefined && !Val)
- return Error(E);
+ if (!Val) {
+ if (BuiltinOp == Builtin::BI__builtin_clzg && E->getNumArgs() > 1) {
+ APSInt Fallback;
+ if (!EvaluateInteger(E->getArg(1), Fallback, Info))
----------------
nickdesaulniers wrote:
Could just reuse `Val` here; we don't need extra storage for `Fallback`.
https://github.com/llvm/llvm-project/pull/86577
More information about the cfe-commits
mailing list