ac/nir: fix nir_op_b2f16
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 8 Apr 2019 07:24:56 +0000 (09:24 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Apr 2019 07:05:55 +0000 (09:05 +0200)
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 f2d527540d8178f19b1afca7e1645b4193c6dfe6..3d2f738edec417efc7291afb13e0e86079575bdf 100644 (file)
@@ -322,10 +322,16 @@ static LLVMValueRef emit_b2f(struct ac_llvm_context *ctx,
                                           "");
        result = LLVMBuildBitCast(ctx->builder, result, ctx->f32, "");
 
-       if (bitsize == 32)
+       switch (bitsize) {
+       case 16:
+               return LLVMBuildFPTrunc(ctx->builder, result, ctx->f16, "");
+       case 32:
                return result;
-
-       return LLVMBuildFPExt(ctx->builder, result, ctx->f64, "");
+       case 64:
+               return LLVMBuildFPExt(ctx->builder, result, ctx->f64, "");
+       default:
+               unreachable("Unsupported bit size.");
+       }
 }
 
 static LLVMValueRef emit_f2b(struct ac_llvm_context *ctx,