From f7374707360644057cd686efd46192e1b0c80c2c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 4 Nov 2024 13:59:36 -0400 Subject: [PATCH] agx: fuse iadd+large shift into imad total instructions in shared programs: 2750352 -> 2750211 (<.01%) instructions in affected programs: 86944 -> 86803 (-0.16%) helped: 32 HURT: 18 Instructions are helped. total alu in shared programs: 2273810 -> 2273669 (<.01%) alu in affected programs: 76720 -> 76579 (-0.18%) helped: 32 HURT: 18 Alu are helped. total fscib in shared programs: 2272127 -> 2271986 (<.01%) fscib in affected programs: 76720 -> 76579 (-0.18%) helped: 32 HURT: 18 Fscib are helped. total bytes in shared programs: 21476424 -> 21475184 (<.01%) bytes in affected programs: 649884 -> 648644 (-0.19%) helped: 33 HURT: 18 Bytes are helped. total regs in shared programs: 865114 -> 865090 (<.01%) regs in affected programs: 525 -> 501 (-4.57%) helped: 3 HURT: 0 total uniforms in shared programs: 2120792 -> 2120848 (<.01%) uniforms in affected programs: 414 -> 470 (13.53%) helped: 0 HURT: 8 Uniforms are HURT. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_nir_algebraic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/asahi/compiler/agx_nir_algebraic.py b/src/asahi/compiler/agx_nir_algebraic.py index 9e2c5aa7e5f..1deac433578 100644 --- a/src/asahi/compiler/agx_nir_algebraic.py +++ b/src/asahi/compiler/agx_nir_algebraic.py @@ -189,6 +189,12 @@ for s in range(1, 5): (('ishl', a, s), iaddshl(0, a, s)), ] +# If the above rules failed, we have a large constant shift on the IC unit. +# Might as well fuse an add to form an imad, if we're on the IC anyway. +fuse_imad += [ + (('iadd', a, ('ishl(is_used_once)', b, '#c')), imad(b, ('ishl', 1, c), a)), +] + # Discard lowering generates this pattern, clean it up ixor_bcsel = [ (('ixor', ('bcsel', a, '#b', '#c'), '#d'),