agx: Optimize multiplies
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 25 Apr 2023 17:52:32 +0000 (13:52 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 11 May 2023 13:23:23 +0000 (09:23 -0400)
commit5a80bf2eb0417c27ce942fb6949df6dab41236b9
tree6397be388278fe911868178d8a1fb4c86e3fe23f
parentc2793a304d4adad9e547d8b65060cd4ac255923e
agx: Optimize multiplies

We have an imad instruction and our iadd has a small immediate shift on the
second source. Together, these allow expressing lots of integer multiplies more
efficiently. Add some rules to optimize these now that the backend compiler can
ingest the optimized forms.

Half-register changes are from load_const scheduling changing in some vertex
shaders.

   total instructions in shared programs: 1539092 -> 1537949 (-0.07%)
   instructions in affected programs: 167896 -> 166753 (-0.68%)

   total bytes in shared programs: 10543012 -> 10533866 (-0.09%)
   bytes in affected programs: 1218068 -> 1208922 (-0.75%)

   total halfregs in shared programs: 483180 -> 483448 (0.06%)
   halfregs in affected programs: 1942 -> 2210 (13.80%)

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22695>
src/asahi/compiler/agx_compile.c
src/asahi/compiler/agx_nir.h
src/asahi/compiler/agx_nir_algebraic.py