[clang] e9fe95a - [clang][bytecode][NFC] Use maxnum/minnum for fmax/fmin (#129643)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 3 22:22:57 PST 2025
Author: Timm Baeder
Date: 2025-03-04T07:22:54+01:00
New Revision: e9fe95acf3b9ead924a6f059c8ca8a8aabc55575
URL: https://github.com/llvm/llvm-project/commit/e9fe95acf3b9ead924a6f059c8ca8a8aabc55575
DIFF: https://github.com/llvm/llvm-project/commit/e9fe95acf3b9ead924a6f059c8ca8a8aabc55575.diff
LOG: [clang][bytecode][NFC] Use maxnum/minnum for fmax/fmin (#129643)
Equivalent of https://github.com/llvm/llvm-project/pull/129630 for the
bytecode interpreter.
Added:
Modified:
clang/lib/AST/ByteCode/InterpBuiltin.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index b964906fb6594..df9c2bc24b15f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -397,21 +397,10 @@ static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC,
const Floating &LHS = getParam<Floating>(Frame, 0);
const Floating &RHS = getParam<Floating>(Frame, 1);
- Floating Result;
-
- if (IsNumBuiltin) {
- Result = llvm::minimumnum(LHS.getAPFloat(), RHS.getAPFloat());
- } else {
- // When comparing zeroes, return -0.0 if one of the zeroes is negative.
- if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
- Result = RHS;
- else if (LHS.isNan() || RHS < LHS)
- Result = RHS;
- else
- Result = LHS;
- }
-
- S.Stk.push<Floating>(Result);
+ if (IsNumBuiltin)
+ S.Stk.push<Floating>(llvm::minimumnum(LHS.getAPFloat(), RHS.getAPFloat()));
+ else
+ S.Stk.push<Floating>(minnum(LHS.getAPFloat(), RHS.getAPFloat()));
return true;
}
@@ -421,21 +410,10 @@ static bool interp__builtin_fmax(InterpState &S, CodePtr OpPC,
const Floating &LHS = getParam<Floating>(Frame, 0);
const Floating &RHS = getParam<Floating>(Frame, 1);
- Floating Result;
-
- if (IsNumBuiltin) {
- Result = llvm::maximumnum(LHS.getAPFloat(), RHS.getAPFloat());
- } else {
- // When comparing zeroes, return +0.0 if one of the zeroes is positive.
- if (LHS.isZero() && RHS.isZero() && LHS.isNegative())
- Result = RHS;
- else if (LHS.isNan() || RHS > LHS)
- Result = RHS;
- else
- Result = LHS;
- }
-
- S.Stk.push<Floating>(Result);
+ if (IsNumBuiltin)
+ S.Stk.push<Floating>(llvm::maximumnum(LHS.getAPFloat(), RHS.getAPFloat()));
+ else
+ S.Stk.push<Floating>(maxnum(LHS.getAPFloat(), RHS.getAPFloat()));
return true;
}
More information about the cfe-commits
mailing list