summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2023-10-13 19:27:03 +0200
committerJosJuice <josjuice@gmail.com>2023-11-28 18:30:45 +0100
commit255ee3fdce7bcdd230357d2bc8f3da143e510494 (patch)
treefdcdf53a639c0dad65a34ef79696e322d7b9c056 /Source/Core/Common
parent5d9838548bd04f5dbd73f597a4c3c29aee1c2625 (diff)
JitArm64: Use LSL+CLS for classifying floats
This is a little trick I came up with that lets us restructure our float classification code so we can exit earlier when the float is normal, which is the case more often than not. First we shift left by 1 to get rid of the sign bit, and then we count the number of leading sign bits. If the result is less than 10 (for doubles) or 7 (for floats), the float is normal. This is because, if the float isn't normal, the exponent is either all zeroes or all ones.
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/FloatUtils.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/Core/Common/FloatUtils.h b/Source/Core/Common/FloatUtils.h
index b1c16d172c..82942c4b19 100644
--- a/Source/Core/Common/FloatUtils.h
+++ b/Source/Core/Common/FloatUtils.h
@@ -23,11 +23,15 @@ static constexpr u64 DOUBLE_SIGN = 0x8000000000000000ULL;
static constexpr u64 DOUBLE_EXP = 0x7FF0000000000000ULL;
static constexpr u64 DOUBLE_FRAC = 0x000FFFFFFFFFFFFFULL;
static constexpr u64 DOUBLE_ZERO = 0x0000000000000000ULL;
+static constexpr int DOUBLE_EXP_WIDTH = 11;
+static constexpr int DOUBLE_FRAC_WIDTH = 52;
static constexpr u32 FLOAT_SIGN = 0x80000000;
static constexpr u32 FLOAT_EXP = 0x7F800000;
static constexpr u32 FLOAT_FRAC = 0x007FFFFF;
static constexpr u32 FLOAT_ZERO = 0x00000000;
+static constexpr int FLOAT_EXP_WIDTH = 8;
+static constexpr int FLOAT_FRAC_WIDTH = 23;
inline bool IsQNAN(double d)
{