llvmpipe: move to nir lowering for fquantize2f16
authorDave Airlie <airlied@redhat.com>
Fri, 1 Sep 2023 05:11:12 +0000 (15:11 +1000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Sep 2023 23:33:20 +0000 (23:33 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24988>

src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/drivers/llvmpipe/lp_screen.c

index d1b9cfc..c56326a 100644 (file)
@@ -576,29 +576,6 @@ do_int_mod(struct lp_build_nir_context *bld_base,
    return LLVMBuildOr(builder, div_mask, result, "");
 }
 
-
-static LLVMValueRef
-do_quantize_to_f16(struct lp_build_nir_context *bld_base,
-                   LLVMValueRef src)
-{
-   struct gallivm_state *gallivm = bld_base->base.gallivm;
-   LLVMBuilderRef builder = gallivm->builder;
-   LLVMValueRef result, cond, cond2, temp;
-
-   result = LLVMBuildFPTrunc(builder, src, bld_base->half_bld.vec_type, "");
-   result = LLVMBuildFPExt(builder, result, bld_base->base.vec_type, "");
-
-   temp = lp_build_abs(get_flt_bld(bld_base, 32), result);
-   cond = LLVMBuildFCmp(builder, LLVMRealOGT,
-                        LLVMBuildBitCast(builder, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, 0x38800000), bld_base->base.vec_type, ""),
-                        temp, "");
-   cond2 = LLVMBuildFCmp(builder, LLVMRealONE, temp, bld_base->base.zero, "");
-   cond = LLVMBuildAnd(builder, cond, cond2, "");
-   result = LLVMBuildSelect(builder, cond, bld_base->base.zero, result, "");
-   return result;
-}
-
-
 static LLVMValueRef
 do_alu_action(struct lp_build_nir_context *bld_base,
               const nir_alu_instr *instr,
@@ -822,9 +799,6 @@ do_alu_action(struct lp_build_nir_context *bld_base,
    case nir_op_fpow:
       result = lp_build_pow(get_flt_bld(bld_base, src_bit_size[0]), src[0], src[1]);
       break;
-   case nir_op_fquantize2f16:
-      result = do_quantize_to_f16(bld_base, src[0]);
-      break;
    case nir_op_frcp:
       result = lp_build_rcp(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
       break;
index aebf2a8..dc286af 100644 (file)
@@ -631,6 +631,7 @@ static const struct nir_shader_compiler_options gallivm_nir_options = {
    .lower_device_index_to_zero = true,
    .support_16bit_alu = true,
    .lower_fisnormal = true,
+   .lower_fquantize2f16 = true,
 };