Skip to content

Commit 875841c

Browse files
authored
[clang][bytecode] Avoid a getValue() call in builtin_isinf (#152939)
Get the APFloat once and work with that, instead of calling isInf() and potentially isNegative().
1 parent 6db3776 commit 875841c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,13 @@ static bool interp__builtin_isinf(InterpState &S, CodePtr OpPC,
459459
const InterpFrame *Frame, bool CheckSign,
460460
const CallExpr *Call) {
461461
const Floating &Arg = S.Stk.pop<Floating>();
462-
bool IsInf = Arg.isInf();
462+
APFloat F = Arg.getAPFloat();
463+
bool IsInf = F.isInfinity();
463464

464465
if (CheckSign)
465-
pushInteger(S, IsInf ? (Arg.isNegative() ? -1 : 1) : 0, Call->getType());
466+
pushInteger(S, IsInf ? (F.isNegative() ? -1 : 1) : 0, Call->getType());
466467
else
467-
pushInteger(S, Arg.isInf(), Call->getType());
468+
pushInteger(S, IsInf, Call->getType());
468469
return true;
469470
}
470471

0 commit comments

Comments
 (0)