nir/algebraic: add pattern for (a << #b) * #c => a * (#c << #b)
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Totals from 2545 (3.19% of 79839) affected shaders: (Navi48)

Instrs: 6371003 -> 6364130 (-0.11%); split: -0.12%, +0.01%
CodeSize: 33827548 -> 33812244 (-0.05%); split: -0.06%, +0.01%
Latency: 47451755 -> 47430108 (-0.05%); split: -0.05%, +0.00%
InvThroughput: 10442450 -> 10437159 (-0.05%); split: -0.05%, +0.00%
SClause: 159829 -> 159874 (+0.03%); split: -0.01%, +0.04%
Copies: 500725 -> 500721 (-0.00%); split: -0.01%, +0.01%
PreSGPRs: 110482 -> 110478 (-0.00%); split: -0.00%, +0.00%
PreVGPRs: 147289 -> 147287 (-0.00%); split: -0.00%, +0.00%
VALU: 3456135 -> 3454241 (-0.05%); split: -0.06%, +0.01%
SALU: 925982 -> 923616 (-0.26%)
VOPD: 1243 -> 1212 (-2.49%)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37173>
This commit is contained in:
Daniel Schürmann 2025-09-04 11:55:50 +02:00 committed by Marge Bot
parent 87f451aa39
commit c78f1d516c

View file

@ -522,9 +522,10 @@ optimizations.extend([
(('ishl', ('iadd', ('imul', a, '#b'), '#c'), '#d'),
('iadd', ('imul', a, ('ishl', b, d)), ('ishl', c, d))),
# (a * #b) << #c
# a * (#b << #c)
# (a * #b) << #c => a * (#b << #c)
(('ishl', ('imul', a, '#b'), '#c'), ('imul', a, ('ishl', b, c))),
# (a << #b) * #c => a * (#c << #b)
(('imul', ('ishl', a, '#b'), '#c'), ('imul', a, ('ishl', c, b))),
])
# Care must be taken here. Shifts in NIR uses only the lower log2(bitsize)