Fix construction of SPIR-V constant float objects

Constructing a constant SIMD::Float is not guaranteed to preserve the
data's exact bit pattern, but SPIR-V provides 32-bit words representing
"the bit pattern for the constant". Thus we must first construct an
integer constant, and bitcast to float.

Bug: b/140302841
Change-Id: I1a84dab9d1adbdc15f8a3b2fc639c637d2841174
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36208
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index a48e3b3..4a28af6 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -1108,17 +1108,21 @@
 
 			RValue<SIMD::Float> Float(uint32_t i) const
 			{
-				if (intermediate != nullptr)
+				if (intermediate)
 				{
 					return intermediate->Float(i);
 				}
-				auto constantValue = reinterpret_cast<float *>(obj.constantValue.get());
-				return SIMD::Float(constantValue[i]);
+
+				// Constructing a constant SIMD::Float is not guaranteed to preserve the data's exact
+				// bit pattern, but SPIR-V provides 32-bit words representing "the bit pattern for the constant".
+				// Thus we must first construct an integer constant, and bitcast to float.
+				auto constantValue = reinterpret_cast<uint32_t *>(obj.constantValue.get());
+				return As<SIMD::Float>(SIMD::UInt(constantValue[i]));
 			}
 
 			RValue<SIMD::Int> Int(uint32_t i) const
 			{
-				if (intermediate != nullptr)
+				if (intermediate)
 				{
 					return intermediate->Int(i);
 				}
@@ -1128,7 +1132,7 @@
 
 			RValue<SIMD::UInt> UInt(uint32_t i) const
 			{
-				if (intermediate != nullptr)
+				if (intermediate)
 				{
 					return intermediate->UInt(i);
 				}