radv/ac: canonicalize the output for 32-bit float min/max.
authorDave Airlie <airlied@redhat.com>
Fri, 17 Mar 2017 03:38:41 +0000 (13:38 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 3 May 2017 02:55:34 +0000 (12:55 +1000)
This fixes:
dEQP-VK.glsl.builtin.precision.min.*
dEQP-VK.glsl.builtin.precision.max.*
dEQP-VK.glsl.builtin.precision.clamp.*

The problem is the hw doesn't compare denorms properly,
so we have to flush them, even though the spec says
flushing is optional, if you don't flush the results
should be correct.

The -pro driver changes the shader float mode,
it would be nice if llvm could grow that perhaps.

Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index dbb8ebedd9381ed0e4500b3321c1f564e91601eb..fccac1a3219d5052f7ff218fb1620bc9ae6c6dd8 100644 (file)
@@ -1748,10 +1748,18 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
        case nir_op_fmax:
                result = emit_intrin_2f_param(ctx, "llvm.maxnum",
                                              to_float_type(ctx, def_type), src[0], src[1]);
+               if (instr->dest.dest.ssa.bit_size == 32)
+                       result = emit_intrin_1f_param(ctx, "llvm.canonicalize",
+                                                     to_float_type(ctx, def_type),
+                                                     result);
                break;
        case nir_op_fmin:
                result = emit_intrin_2f_param(ctx, "llvm.minnum",
                                              to_float_type(ctx, def_type), src[0], src[1]);
+               if (instr->dest.dest.ssa.bit_size == 32)
+                       result = emit_intrin_1f_param(ctx, "llvm.canonicalize",
+                                                     to_float_type(ctx, def_type),
+                                                     result);
                break;
        case nir_op_ffma:
                result = emit_intrin_3f_param(ctx, "llvm.fma",