ac/nir: implement nir_op_f2b
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sun, 25 Jun 2017 10:57:02 +0000 (12:57 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 27 Jun 2017 00:28:30 +0000 (10:28 +1000)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index 8c781f2a79ee62cc3335f547251af1d6b225af59..aec5d39e53e36c833eff9bcab7b8cfa03d84553d 100644 (file)
@@ -1287,6 +1287,15 @@ static LLVMValueRef emit_b2f(struct nir_to_llvm_context *ctx,
        return LLVMBuildAnd(ctx->builder, src0, LLVMBuildBitCast(ctx->builder, LLVMConstReal(ctx->f32, 1.0), ctx->i32, ""), "");
 }
 
+static LLVMValueRef emit_f2b(struct ac_llvm_context *ctx,
+                            LLVMValueRef src0)
+{
+       src0 = to_float(ctx, src0);
+       return LLVMBuildSExt(ctx->builder,
+                            LLVMBuildFCmp(ctx->builder, LLVMRealUNE, src0, ctx->f32_0, ""),
+                            ctx->i32, "");
+}
+
 static LLVMValueRef emit_b2i(struct ac_llvm_context *ctx,
                             LLVMValueRef src0)
 {
@@ -1822,6 +1831,9 @@ static void visit_alu(struct nir_to_llvm_context *ctx, const nir_alu_instr *inst
        case nir_op_b2f:
                result = emit_b2f(ctx, src[0]);
                break;
+       case nir_op_f2b:
+               result = emit_f2b(&ctx->ac, src[0]);
+               break;
        case nir_op_b2i:
                result = emit_b2i(&ctx->ac, src[0]);
                break;