Eliminate incorrect Exponent() function

The Exponent() helper function did not return the actual exponent of an
IEEE 754 single-precision value. The exponent bias is 127, not 126, but
the latter is correct for implementing frexp() since the significant is
in the [0.5, 1.0) range while mantissas represent [1.0, 2.0). So the
Exponent() function was eliminated and its logic inlined in Frexp().

Bug: b/243791551
Change-Id: I18eaa6930c4583468e6129126d64227f30fd9696
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/67889
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Pipeline/ShaderCore.cpp b/src/Pipeline/ShaderCore.cpp
index 8e42292..1c12a06 100644
--- a/src/Pipeline/ShaderCore.cpp
+++ b/src/Pipeline/ShaderCore.cpp
@@ -520,7 +520,7 @@
 	auto v = As<SIMD::Int>(val);
 	auto significand = As<SIMD::Float>((v & 0x807FFFFF) | (0x3F000000 & isNotZero));
 
-	auto exponent = Exponent(val) & isNotZero;
+	auto exponent = (((v >> 23) & 0xFF) - 126) & isNotZero;
 
 	return std::make_pair(significand, exponent);
 }
@@ -959,14 +959,6 @@
 	return NthBit32(bitCount) - SIMD::UInt(1);
 }
 
-// Returns the exponent of the floating point number f.
-// Assumes IEEE 754
-rr::RValue<SIMD::Int> Exponent(rr::RValue<SIMD::Float> f)
-{
-	auto v = rr::As<SIMD::UInt>(f);
-	return (SIMD::Int((v >> SIMD::UInt(23)) & SIMD::UInt(0xFF)) - SIMD::Int(126));
-}
-
 // Returns y if y < x; otherwise result is x.
 // If one operand is a NaN, the other operand is the result.
 // If both operands are NaN, the result is a NaN.
diff --git a/src/Pipeline/ShaderCore.hpp b/src/Pipeline/ShaderCore.hpp
index 01993d0..3f1427e 100644
--- a/src/Pipeline/ShaderCore.hpp
+++ b/src/Pipeline/ShaderCore.hpp
@@ -215,10 +215,6 @@
     rr::RValue<SIMD::Float> const &b,
     rr::RValue<SIMD::Float> const &c);
 
-// Returns the exponent of the floating point number f.
-// Assumes IEEE 754
-rr::RValue<SIMD::Int> Exponent(rr::RValue<SIMD::Float> f);
-
 // Returns y if y < x; otherwise result is x.
 // If one operand is a NaN, the other operand is the result.
 // If both operands are NaN, the result is a NaN.