From 3a2a00540469fa40b44cd0481ffae0e91b423a9b Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Wed, 16 Dec 2020 23:03:29 +1300 Subject: [PATCH] pan/gen_pack: Fix signed integer packing Any excess sign-extend bits would spill into adjacent fields, so mask off anything after the end bit. Shift from 2 instead of 1, because there needs to be one extra bit in the mask as 'end' is inclusive. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/gen_pack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panfrost/lib/gen_pack.py b/src/panfrost/lib/gen_pack.py index c70b8b3a6e9..bb17bd53ffd 100644 --- a/src/panfrost/lib/gen_pack.py +++ b/src/panfrost/lib/gen_pack.py @@ -78,7 +78,7 @@ __gen_sint(int32_t v, uint32_t start, uint32_t end) } #endif - return ((uint32_t) v) << start; + return (((uint32_t) v) << start) & ((2ll << end) - 1); } static inline uint32_t