diff --git a/src/asahi/lib/gen_pack.py b/src/asahi/lib/gen_pack.py index 4fd3eb14669..6f6f3518e5d 100644 --- a/src/asahi/lib/gen_pack.py +++ b/src/asahi/lib/gen_pack.py @@ -117,8 +117,7 @@ __gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end) int size = end - start + 1; int64_t val = __gen_unpack_uint(cl, start, end); - /* Get the sign bit extended. */ - return (val << (64 - size)) >> (64 - size); + return util_sign_extend(val, size); } #define agx_prepare(dst, T) \\ diff --git a/src/panfrost/lib/genxml/gen_pack.py b/src/panfrost/lib/genxml/gen_pack.py index f6b1a0f691c..7a177b138a3 100644 --- a/src/panfrost/lib/genxml/gen_pack.py +++ b/src/panfrost/lib/genxml/gen_pack.py @@ -118,8 +118,7 @@ __gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end) int size = end - start + 1; int64_t val = __gen_unpack_uint(cl, start, end); - /* Get the sign bit extended. */ - return (val << (64 - size)) >> (64 - size); + return util_sign_extend(val, size); } static inline uint64_t