agx: Fix length bit confusion

Man, this expression was wrong. First of all, raw is 64-bit so our mask needs to
be too. Second, length is in bytes -- not bits -- so we need to multiply by 8 to
get something sensible. In effect, the old wrong expression would always use the
long encoding for ALU instructions... whoops. This particular bug probably goes
back to the very first version of agx_pack...

Massive improvement in code density. Noticed while comparing assembly with the
blob. It's my Saturday, I can pointless optimize if I want to.

   total bytes in shared programs: 12175112 -> 11720338 (-3.74%)
   bytes in affected programs: 11963800 -> 11509026 (-3.80%)
   helped: 16624
   HURT: 0
   Bytes are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>
This commit is contained in:
Alyssa Rosenzweig 2023-07-29 21:54:58 -04:00 committed by Marge Bot
parent e83b708676
commit 85d6f162ad

View file

@ -480,7 +480,7 @@ agx_pack_alu(struct util_dynarray *emission, agx_instr *I)
/* Determine length bit */
unsigned length = encoding.length_short;
unsigned short_mask = (1 << length) - 1;
uint64_t short_mask = BITFIELD64_MASK(8 * length);
bool length_bit = (extend || (raw & ~short_mask));
if (encoding.extensible && length_bit) {