From d45f598ece6bde60959ff2631ebc747b57197677 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 1 Sep 2023 15:11:12 +1000 Subject: [PATCH] llvmpipe: move to nir lowering for fquantize2f16 Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 26 -------------------------- src/gallium/drivers/llvmpipe/lp_screen.c | 1 + 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index d1b9cfc..c56326a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -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; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index aebf2a8..dc286af 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -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, }; -- 2.7.4