From d664f6a1e4739d0fd1adc9428793b218e4581abe Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Thu, 19 Mar 2026 18:34:24 +0100 Subject: [PATCH] gallivm: remove dead code in lp_build_add Reviewed-by: Konstantin Seurer Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 45 +-------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 399cc0ff353..1b726f16e69 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -423,39 +423,15 @@ lp_build_add(struct lp_build_context *bld, return bld->undef; if (type.norm) { - const char *intrinsic = NULL; - if (!type.sign && (a == bld->one || b == bld->one)) return bld->one; if (!type.floating && !type.fixed) { char intrin[32]; - intrinsic = type.sign ? "llvm.sadd.sat" : "llvm.uadd.sat"; + const char *intrinsic = type.sign ? "llvm.sadd.sat" : "llvm.uadd.sat"; lp_format_intrinsic(intrin, sizeof intrin, intrinsic, bld->vec_type); return lp_build_intrinsic_binary(builder, intrin, bld->vec_type, a, b); } - - if (intrinsic) - return lp_build_intrinsic_binary(builder, intrinsic, - lp_build_vec_type(bld->gallivm, bld->type), a, b); - } - - if (type.norm && !type.floating && !type.fixed) { - if (type.sign) { - uint64_t sign = (uint64_t)1 << (type.width - 1); - LLVMValueRef max_val = lp_build_const_int_vec(bld->gallivm, type, sign - 1); - LLVMValueRef min_val = lp_build_const_int_vec(bld->gallivm, type, sign); - /* a_clamp_max is the maximum a for positive b, - a_clamp_min is the minimum a for negative b. */ - LLVMValueRef a_clamp_max = - lp_build_min_simple(bld, a, LLVMBuildSub(builder, max_val, b, ""), - GALLIVM_NAN_BEHAVIOR_UNDEFINED); - LLVMValueRef a_clamp_min = - lp_build_max_simple(bld, a, LLVMBuildSub(builder, min_val, b, ""), - GALLIVM_NAN_BEHAVIOR_UNDEFINED); - a = lp_build_select(bld, lp_build_cmp(bld, PIPE_FUNC_GREATER, b, - bld->zero), a_clamp_max, a_clamp_min); - } } if (type.floating) @@ -467,25 +443,6 @@ lp_build_add(struct lp_build_context *bld, if (bld->type.norm && (bld->type.floating || bld->type.fixed)) res = lp_build_min_simple(bld, res, bld->one, GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN); - if (type.norm && !type.floating && !type.fixed) { - if (!type.sign) { - /* - * newer llvm versions no longer support the intrinsics, but recognize - * the pattern. Since auto-upgrade of intrinsics doesn't work for jit - * code, it is important we match the pattern llvm uses (and pray llvm - * doesn't change it - and hope they decide on the same pattern for - * all backends supporting it...). - * NOTE: cmp/select does sext/trunc of the mask. Does not seem to - * interfere with llvm's ability to recognize the pattern but seems - * a bit brittle. - * NOTE: llvm 9+ always uses (non arch specific) intrinsic. - */ - LLVMValueRef overflowed = lp_build_cmp(bld, PIPE_FUNC_GREATER, a, res); - res = lp_build_select(bld, overflowed, - LLVMConstAllOnes(bld->int_vec_type), res); - } - } - /* XXX clamp to floor of -1 or 0??? */ return res;