diff options
author | Timothy Arceri <[email protected]> | 2018-01-11 22:10:47 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2018-01-12 09:29:18 +1100 |
commit | 30c1a93f6de66f0b9f86e11b517b62f57f330d95 (patch) | |
tree | e915762be965958396bde321804700023cc237ac /src/amd | |
parent | d7b6b8ba52894488b3234bc5fb09c0caebcc202b (diff) |
ac/nir: fix translation of nir_op_fsign for doubles
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 <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 7b348d97f0a..6ab93b36783 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1338,14 +1338,26 @@ static LLVMValueRef emit_iabs(struct ac_llvm_context *ctx, } static LLVMValueRef emit_fsign(struct ac_llvm_context *ctx, - LLVMValueRef src0) + LLVMValueRef src0, + unsigned bitsize) { - LLVMValueRef cmp, val; + LLVMValueRef cmp, val, zero, one; + LLVMTypeRef type; + + if (bitsize == 32) { + type = ctx->f32; + zero = ctx->f32_0; + one = ctx->f32_1; + } else { + type = ctx->f64; + zero = ctx->f64_0; + one = ctx->f64_1; + } - cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGT, src0, ctx->f32_0, ""); - val = LLVMBuildSelect(ctx->builder, cmp, ctx->f32_1, src0, ""); - cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGE, val, ctx->f32_0, ""); - val = LLVMBuildSelect(ctx->builder, cmp, val, LLVMConstReal(ctx->f32, -1.0), ""); + cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGT, src0, zero, ""); + val = LLVMBuildSelect(ctx->builder, cmp, one, src0, ""); + cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGE, val, zero, ""); + val = LLVMBuildSelect(ctx->builder, cmp, val, LLVMConstReal(type, -1.0), ""); return val; } @@ -1799,7 +1811,7 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) break; case nir_op_fsign: src[0] = ac_to_float(&ctx->ac, src[0]); - result = emit_fsign(&ctx->ac, src[0]); + result = emit_fsign(&ctx->ac, src[0], instr->dest.dest.ssa.bit_size); break; case nir_op_ffloor: result = emit_intrin_1f_param(&ctx->ac, "llvm.floor", |