[clang] [clang] Implement constexpr support for __builtin_{clzg, ctzg} (PR #86577)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 25 15:21:06 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) {
----------------
overmighty wrote:

I'm not sure I understand. What would the `...` in `return Success(...` be? If the first argument is not zero then the builtin returns the leading/trailing zero count of that, even when called with 2 arguments, so we can't just `return Success(Val.count{l,r}_zero(), E);` on line 12379 of your suggested change as it would always return the second argument when the builtin is called with 2 arguments.

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


More information about the cfe-commits mailing list