[clang] [clang] Implement constexpr support for __builtin_{clzg, ctzg} (PR #86577)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 26 13:40:40 PDT 2024
================
@@ -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))
----------------
overmighty wrote:
Oops. I will fix this now.
https://github.com/llvm/llvm-project/pull/86577
More information about the cfe-commits
mailing list