[Mesa-dev] [PATCH] radeon/llvm: fix literals inlining

Vadim Girlin vadimgirlin at gmail.com
Sat Dec 15 05:53:26 PST 2012


Use bitwise comparison to check whether we can replace float literal
with inline constant (0.0, 0.5, 1.0), otherwise we can get unexpected
results for integer literals bitcasted to float.

Fixes lockup with glsl-fs-unroll-out-param.shader_test on evergreen.

Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
---
 lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp b/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp
index d15ed39..755936b 100644
--- a/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp
+++ b/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp
@@ -185,12 +185,11 @@ SDNode *AMDGPUDAGToDAGISel::Select(SDNode *N) {
 
       ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(N);
       APFloat Value = C->getValueAPF();
-      float FloatValue = Value.convertToFloat();
-      if (FloatValue == 0.0) {
+      if (Value.bitwiseIsEqual(APFloat(0.0))) {
         ImmReg = AMDGPU::ZERO;
-      } else if (FloatValue == 0.5) {
+      } else if (Value.bitwiseIsEqual(APFloat(0.5))) {
         ImmReg = AMDGPU::HALF;
-      } else if (FloatValue == 1.0) {
+      } else if (Value.bitwiseIsEqual(APFloat(1.0))) {
         ImmReg = AMDGPU::ONE;
       } else {
         ImmValue = Value.bitcastToAPInt().getZExtValue();
-- 
1.8.0.2



More information about the mesa-dev mailing list