gallivm: Use llvm.roundeven in lp_build_round()

`lp_build_round` intends to implement round with ties-to-even behavior,
as can be seen by its test's use of `nearbyint` to generate reference
values and by it use in implementing `nir_op_fround_even`.

Fixes: 0d3b285360 ("gallivm: use llvm intrinsics for 16-bit round/trunc/roundeven")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34937>
(cherry picked from commit eea3ed6a37)
This commit is contained in:
Matt Turner 2025-05-12 12:38:17 -04:00 committed by Eric Engestrom
parent 6865ce622d
commit 791c1ce754
3 changed files with 3 additions and 10 deletions

View file

@ -3454,7 +3454,7 @@
"description": "gallivm: Use `llvm.roundeven` in lp_build_round()",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "0d3b2853600cf6934a3a09deaf435944d18d833a",
"notes": null

View file

@ -2100,7 +2100,7 @@ lp_build_round(struct lp_build_context *bld,
if (type.width == 16) {
char intrinsic[64];
lp_format_intrinsic(intrinsic, 64, "llvm.round", bld->vec_type);
lp_format_intrinsic(intrinsic, 64, "llvm.roundeven", bld->vec_type);
return lp_build_intrinsic_unary(builder, intrinsic, bld->vec_type, a);
}

View file

@ -776,14 +776,7 @@ do_alu_action(struct lp_build_nir_context *bld_base,
result = lp_build_rcp(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
break;
case nir_op_fround_even:
if (src_bit_size[0] == 16) {
struct lp_build_context *bld = get_flt_bld(bld_base, 16);
char intrinsic[64];
lp_format_intrinsic(intrinsic, 64, "llvm.roundeven", bld->vec_type);
result = lp_build_intrinsic_unary(builder, intrinsic, bld->vec_type, src[0]);
} else {
result = lp_build_round(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
}
result = lp_build_round(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
break;
case nir_op_frsq:
result = lp_build_rsqrt(get_flt_bld(bld_base, src_bit_size[0]), src[0]);