Fix ldexp builtin with vectors
In a few places we were always looking at component 0, which obviously
doesn't go well.
Bug: b/140648938
Test: dEQP-VK.*ldexp*
Change-Id: I6a8698a56beab8ccc3b41a729d399b957cde9495
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36113
Tested-by: Chris Forbes <chrisforbes@google.com>
Presubmit-Ready: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 63d403c..89a82ba 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -4229,7 +4229,7 @@
auto in = significand.Float(i);
auto significandExponent = Exponent(in);
auto combinedExponent = exponent.Int(i) + significandExponent;
- auto isSignificandZero = SIMD::UInt(CmpEQ(significand.Int(0), SIMD::Int(0)));
+ auto isSignificandZero = SIMD::UInt(CmpEQ(significand.Int(i), SIMD::Int(0)));
auto isSignificandInf = SIMD::UInt(IsInf(in));
auto isSignificandNaN = SIMD::UInt(IsNan(in));
auto isExponentNotTooSmall = SIMD::UInt(CmpGE(combinedExponent, SIMD::Int(-126)));
@@ -4247,7 +4247,7 @@
// If the input significand is zero, inf or nan, just return the
// input significand.
auto passthrough = isSignificandZero | isSignificandInf | isSignificandNaN;
- v = (v & ~passthrough) | (significand.UInt(0) & passthrough);
+ v = (v & ~passthrough) | (significand.UInt(i) & passthrough);
dst.move(i, As<SIMD::Float>(v));
}