nir: Use util_mask_sign_extend when serializing constants

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17214>
This commit is contained in:
Jason Ekstrand 2022-07-01 13:50:58 -05:00 committed by Marge Bot
parent 642283a2c1
commit bfbcd966f3
1 changed files with 2 additions and 2 deletions

View File

@ -1319,7 +1319,7 @@ write_load_const(write_ctx *ctx, const nir_load_const_instr *lc)
/* packed_value contains high 19 bits, low bits are 0 */
header.load_const.packing = load_const_scalar_hi_19bits;
header.load_const.packed_value = lc->value[0].u64 >> 45;
} else if (util_sign_extend(lc->value[0].i64 & BITFIELD64_MASK(19), 19) == lc->value[0].i64) {
} else if (util_mask_sign_extend(lc->value[0].i64, 19) == lc->value[0].i64) {
/* packed_value contains low 19 bits, high bits are sign-extended */
header.load_const.packing = load_const_scalar_lo_19bits_sext;
header.load_const.packed_value = lc->value[0].u64;
@ -1330,7 +1330,7 @@ write_load_const(write_ctx *ctx, const nir_load_const_instr *lc)
if ((lc->value[0].u32 & 0x1fff) == 0) {
header.load_const.packing = load_const_scalar_hi_19bits;
header.load_const.packed_value = lc->value[0].u32 >> 13;
} else if (util_sign_extend(lc->value[0].i32 & BITFIELD_MASK(19), 19) == lc->value[0].i32) {
} else if (util_mask_sign_extend(lc->value[0].i32, 19) == lc->value[0].i32) {
header.load_const.packing = load_const_scalar_lo_19bits_sext;
header.load_const.packed_value = lc->value[0].u32;
}