Module: Mesa
Branch: master
Commit: 80c71cbbd87eacf850c250483cb533768e203cd3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=80c71cbbd87eacf850c250483cb533768e203cd3

Author: Samuel Pitoiset <[email protected]>
Date:   Fri Nov  8 15:57:02 2019 +0100

ac: add 16-bit float support to ac_build_alu_op()

Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>

---

 src/amd/llvm/ac_llvm_build.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index d97dd36480a..d418ee5ab71 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -4005,6 +4005,7 @@ static LLVMValueRef
 ac_build_alu_op(struct ac_llvm_context *ctx, LLVMValueRef lhs, LLVMValueRef 
rhs, nir_op op)
 {
        bool _64bit = ac_get_type_size(LLVMTypeOf(lhs)) == 8;
+       bool _32bit = ac_get_type_size(LLVMTypeOf(lhs)) == 4;
        switch (op) {
        case nir_op_iadd: return LLVMBuildAdd(ctx->builder, lhs, rhs, "");
        case nir_op_fadd: return LLVMBuildFAdd(ctx->builder, lhs, rhs, "");
@@ -4017,8 +4018,8 @@ ac_build_alu_op(struct ac_llvm_context *ctx, LLVMValueRef 
lhs, LLVMValueRef rhs,
                                        LLVMBuildICmp(ctx->builder, LLVMIntULT, 
lhs, rhs, ""),
                                        lhs, rhs, "");
        case nir_op_fmin: return ac_build_intrinsic(ctx,
-                                       _64bit ? "llvm.minnum.f64" : 
"llvm.minnum.f32",
-                                       _64bit ? ctx->f64 : ctx->f32,
+                                       _64bit ? "llvm.minnum.f64" : _32bit ? 
"llvm.minnum.f32" : "llvm.minnum.f16",
+                                       _64bit ? ctx->f64 : _32bit ? ctx->f32 : 
ctx->f16,
                                        (LLVMValueRef[]){lhs, rhs}, 2, 
AC_FUNC_ATTR_READNONE);
        case nir_op_imax: return LLVMBuildSelect(ctx->builder,
                                        LLVMBuildICmp(ctx->builder, LLVMIntSGT, 
lhs, rhs, ""),
@@ -4027,8 +4028,8 @@ ac_build_alu_op(struct ac_llvm_context *ctx, LLVMValueRef 
lhs, LLVMValueRef rhs,
                                        LLVMBuildICmp(ctx->builder, LLVMIntUGT, 
lhs, rhs, ""),
                                        lhs, rhs, "");
        case nir_op_fmax: return ac_build_intrinsic(ctx,
-                                       _64bit ? "llvm.maxnum.f64" : 
"llvm.maxnum.f32",
-                                       _64bit ? ctx->f64 : ctx->f32,
+                                       _64bit ? "llvm.maxnum.f64" : _32bit ? 
"llvm.maxnum.f32" : "llvm.maxnum.f16",
+                                       _64bit ? ctx->f64 : _32bit ? ctx->f32 : 
ctx->f16,
                                        (LLVMValueRef[]){lhs, rhs}, 2, 
AC_FUNC_ATTR_READNONE);
        case nir_op_iand: return LLVMBuildAnd(ctx->builder, lhs, rhs, "");
        case nir_op_ior: return LLVMBuildOr(ctx->builder, lhs, rhs, "");

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to