mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 15:58:05 +02:00
gallivm: remove dead code in lp_build_add
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40520>
This commit is contained in:
parent
284b4143f7
commit
d664f6a1e4
1 changed files with 1 additions and 44 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue