ac/nir: fix translation of nir_op_frsq for doubles
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 11 Jan 2018 06:04:22 +0000 (17:04 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 11 Jan 2018 22:29:17 +0000 (09:29 +1100)
Without this we end up with the llvm error message:

"Both operands to a binary operator are not of the same type!"

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_nir_to_llvm.c

index 7153c9708d418c723ffa3c5c352b6ffdcb4e2ed0..372a424ce5102fbd9ca0bd1c8f71250298babbce 100644 (file)
@@ -1842,7 +1842,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
        case nir_op_frsq:
                result = emit_intrin_1f_param(&ctx->ac, "llvm.sqrt",
                                              ac_to_float_type(&ctx->ac, def_type), src[0]);
-               result = ac_build_fdiv(&ctx->ac, ctx->ac.f32_1, result);
+               result = ac_build_fdiv(&ctx->ac, instr->dest.dest.ssa.bit_size == 32 ? ctx->ac.f32_1 : ctx->ac.f64_1,
+                                      result);
                break;
        case nir_op_fpow:
                result = emit_intrin_2f_param(&ctx->ac, "llvm.pow",