[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:22:02 PDT 2024
================
@@ -12410,12 +12420,22 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
case Builtin::BI__builtin_ctz:
case Builtin::BI__builtin_ctzl:
case Builtin::BI__builtin_ctzll:
- case Builtin::BI__builtin_ctzs: {
+ case Builtin::BI__builtin_ctzs:
+ case Builtin::BI__builtin_ctzg: {
APSInt Val;
if (!EvaluateInteger(E->getArg(0), Val, Info))
return false;
- if (!Val)
+
+ if (!Val) {
+ if (BuiltinOp == Builtin::BI__builtin_ctzg && E->getNumArgs() > 1) {
+ APSInt Fallback;
+ if (!EvaluateInteger(E->getArg(1), Fallback, Info))
----------------
nickdesaulniers wrote:
Reuse `Val`?
https://github.com/llvm/llvm-project/pull/86577
More information about the cfe-commits
mailing list