ac/nir: only canonicalize 32-bit float min/max outputs on pre-GFX9
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 24 Jan 2018 11:31:40 +0000 (12:31 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 26 Jan 2018 11:14:27 +0000 (12:14 +0100)
According to LLVM, only pre-GFX9 targets do not flush denorms
for fmin/fmax.

All dEQP-VK.glsl.builtin.precision.* still pass.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_nir_to_llvm.c

index 7b56edf8e78c8620bd433f25d7cb5af2135b0aa3..581ccf63c9a80dfd2734f67db23217268d745771 100644 (file)
@@ -1913,18 +1913,24 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
        case nir_op_fmax:
                result = emit_intrin_2f_param(&ctx->ac, "llvm.maxnum",
                                              ac_to_float_type(&ctx->ac, def_type), src[0], src[1]);
-               if (instr->dest.dest.ssa.bit_size == 32)
+               if (ctx->ac.chip_class < GFX9 &&
+                   instr->dest.dest.ssa.bit_size == 32) {
+                       /* Only pre-GFX9 chips do not flush denorms. */
                        result = emit_intrin_1f_param(&ctx->ac, "llvm.canonicalize",
                                                      ac_to_float_type(&ctx->ac, def_type),
                                                      result);
+               }
                break;
        case nir_op_fmin:
                result = emit_intrin_2f_param(&ctx->ac, "llvm.minnum",
                                              ac_to_float_type(&ctx->ac, def_type), src[0], src[1]);
-               if (instr->dest.dest.ssa.bit_size == 32)
+               if (ctx->ac.chip_class < GFX9 &&
+                   instr->dest.dest.ssa.bit_size == 32) {
+                       /* Only pre-GFX9 chips do not flush denorms. */
                        result = emit_intrin_1f_param(&ctx->ac, "llvm.canonicalize",
                                                      ac_to_float_type(&ctx->ac, def_type),
                                                      result);
+               }
                break;
        case nir_op_ffma:
                result = emit_intrin_3f_param(&ctx->ac, "llvm.fmuladd",