Skip to content

Commit 8d9c86c

Browse files
committed
Replaced callback for ffs #160288
1 parent b08aa33 commit 8d9c86c

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -727,17 +727,6 @@ static bool interp__builtin_rotate(InterpState &S, CodePtr OpPC,
727727
return true;
728728
}
729729

730-
static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC,
731-
const InterpFrame *Frame,
732-
const CallExpr *Call) {
733-
PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType());
734-
APSInt Value = popToAPSInt(S.Stk, ArgT);
735-
736-
uint64_t N = Value.countr_zero();
737-
pushInteger(S, N == Value.getBitWidth() ? 0 : N + 1, Call->getType());
738-
return true;
739-
}
740-
741730
static bool interp__builtin_addressof(InterpState &S, CodePtr OpPC,
742731
const InterpFrame *Frame,
743732
const CallExpr *Call) {
@@ -3057,7 +3046,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
30573046
case Builtin::BI__builtin_ffs:
30583047
case Builtin::BI__builtin_ffsl:
30593048
case Builtin::BI__builtin_ffsll:
3060-
return interp__builtin_ffs(S, OpPC, Frame, Call);
3049+
return interp__builtin_elementwise_int_unaryop(S, OpPC, Call, [](const APSInt& Val){ return APInt(Val.getBitWidth(), (Val.countTrailingZeros()==Val.getBitWidth()) ? 0u : (Val.countTrailingZeros()+1u)); });
30613050

30623051
case Builtin::BIaddressof:
30633052
case Builtin::BI__addressof:

0 commit comments

Comments
 (0)