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

Tom Stellard tom at stellard.net
Mon Dec 17 06:50:36 PST 2012


On Sat, Dec 15, 2012 at 05:53:26PM +0400, Vadim Girlin wrote:
> 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.
> 

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

> 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
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list