Skip to content

Commit e9fe95a

Browse files
authored
[clang][bytecode][NFC] Use maxnum/minnum for fmax/fmin (#129643)
Equivalent of #129630 for the bytecode interpreter.
1 parent af4ec59 commit e9fe95a

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -397,21 +397,10 @@ static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC,
397397
const Floating &LHS = getParam<Floating>(Frame, 0);
398398
const Floating &RHS = getParam<Floating>(Frame, 1);
399399

400-
Floating Result;
401-
402-
if (IsNumBuiltin) {
403-
Result = llvm::minimumnum(LHS.getAPFloat(), RHS.getAPFloat());
404-
} else {
405-
// When comparing zeroes, return -0.0 if one of the zeroes is negative.
406-
if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
407-
Result = RHS;
408-
else if (LHS.isNan() || RHS < LHS)
409-
Result = RHS;
410-
else
411-
Result = LHS;
412-
}
413-
414-
S.Stk.push<Floating>(Result);
400+
if (IsNumBuiltin)
401+
S.Stk.push<Floating>(llvm::minimumnum(LHS.getAPFloat(), RHS.getAPFloat()));
402+
else
403+
S.Stk.push<Floating>(minnum(LHS.getAPFloat(), RHS.getAPFloat()));
415404
return true;
416405
}
417406

@@ -421,21 +410,10 @@ static bool interp__builtin_fmax(InterpState &S, CodePtr OpPC,
421410
const Floating &LHS = getParam<Floating>(Frame, 0);
422411
const Floating &RHS = getParam<Floating>(Frame, 1);
423412

424-
Floating Result;
425-
426-
if (IsNumBuiltin) {
427-
Result = llvm::maximumnum(LHS.getAPFloat(), RHS.getAPFloat());
428-
} else {
429-
// When comparing zeroes, return +0.0 if one of the zeroes is positive.
430-
if (LHS.isZero() && RHS.isZero() && LHS.isNegative())
431-
Result = RHS;
432-
else if (LHS.isNan() || RHS > LHS)
433-
Result = RHS;
434-
else
435-
Result = LHS;
436-
}
437-
438-
S.Stk.push<Floating>(Result);
413+
if (IsNumBuiltin)
414+
S.Stk.push<Floating>(llvm::maximumnum(LHS.getAPFloat(), RHS.getAPFloat()));
415+
else
416+
S.Stk.push<Floating>(maxnum(LHS.getAPFloat(), RHS.getAPFloat()));
439417
return true;
440418
}
441419

0 commit comments

Comments
 (0)