ac/nir: fix translation of nir_op_frcp for doubles
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 11 Jan 2018 10:11:00 +0000 (21:11 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 11 Jan 2018 22:29:18 +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 372a424ce5102fbd9ca0bd1c8f71250298babbce..7b348d97f0a086346e393be605c91f8fb2dd1589 100644 (file)
@@ -1715,7 +1715,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
                break;
        case nir_op_frcp:
                src[0] = ac_to_float(&ctx->ac, src[0]);
-               result = ac_build_fdiv(&ctx->ac, ctx->ac.f32_1, src[0]);
+               result = ac_build_fdiv(&ctx->ac, instr->dest.dest.ssa.bit_size == 32 ? ctx->ac.f32_1 : ctx->ac.f64_1,
+                                      src[0]);
                break;
        case nir_op_iand:
                result = LLVMBuildAnd(ctx->ac.builder, src[0], src[1], "");