================ @@ -12354,21 +12354,31 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, case Builtin::BI__builtin_clzl: case Builtin::BI__builtin_clzll: case Builtin::BI__builtin_clzs: + case Builtin::BI__builtin_clzg: case Builtin::BI__lzcnt16: // Microsoft variants of count leading-zeroes case Builtin::BI__lzcnt: case Builtin::BI__lzcnt64: { APSInt Val; if (!EvaluateInteger(E->getArg(0), Val, Info)) return false; - // When the argument is 0, the result of GCC builtins is undefined, whereas - // for Microsoft intrinsics, the result is the bit-width of the argument. - bool ZeroIsUndefined = BuiltinOp != Builtin::BI__lzcnt16 && - BuiltinOp != Builtin::BI__lzcnt && - BuiltinOp != Builtin::BI__lzcnt64; + if (!Val) { + if (BuiltinOp == Builtin::BI__builtin_clzg && E->getNumArgs() > 1) { + if (!EvaluateInteger(E->getArg(1), Val, Info)) ---------------- efriedma-quic wrote:
This EvaluateInteger call can't be guarded by the `if (!Val)` check: even if we don't actually use the value of the second argument, we have to evaluate it for side-effects. We don't want short-circuit the evaluation like for `&&`/`||`. https://github.com/llvm/llvm-project/pull/86577 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits