mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-15 22:08:17 +02:00
nir/algebraic: Optimize zero comparisons of umax or umin
I observered some of the existing patterns stopped being applied after some of the ult-to-ieq optimizations in !33498. It turns out that these patterns occur even without those changes. shader-db: All Intel platforms had similar results. (Lunar Lake shown) total instructions in shared programs: 16973339 -> 16973331 (<.01%) instructions in affected programs: 7977 -> 7969 (-0.10%) helped: 2 / HURT: 0 total cycles in shared programs: 915620938 -> 915620774 (<.01%) cycles in affected programs: 136022 -> 135858 (-0.12%) helped: 2 / HURT: 0 fossil-db: Lunar Lake Totals: Instrs: 209748173 -> 209748011 (-0.00%); split: -0.00%, +0.00% Cycle count: 30514361348 -> 30514920286 (+0.00%); split: -0.00%, +0.00% Spill count: 511813 -> 511808 (-0.00%) Fill count: 622537 -> 622533 (-0.00%) Max live registers: 65477033 -> 65477183 (+0.00%); split: -0.00%, +0.00% Non SSA regs after NIR: 237334728 -> 237334726 (-0.00%); split: -0.00%, +0.00% Totals from 26 (0.00% of 706651) affected shaders: Instrs: 332073 -> 331911 (-0.05%); split: -0.05%, +0.00% Cycle count: 959758560 -> 960317498 (+0.06%); split: -0.03%, +0.09% Spill count: 10293 -> 10288 (-0.05%) Fill count: 23784 -> 23780 (-0.02%) Max live registers: 9682 -> 9832 (+1.55%); split: -0.08%, +1.63% Non SSA regs after NIR: 232135 -> 232133 (-0.00%); split: -0.03%, +0.03% Meteor Lake and DG2 had similar results. (Meteor Lake shown) Totals: Instrs: 233538532 -> 233536113 (-0.00%); split: -0.00%, +0.00% Cycle count: 24428142259 -> 24426705655 (-0.01%); split: -0.01%, +0.00% Spill count: 513128 -> 512923 (-0.04%) Fill count: 557329 -> 557108 (-0.04%) Max live registers: 42129806 -> 42129881 (+0.00%); split: -0.00%, +0.00% Non SSA regs after NIR: 256711720 -> 256711718 (-0.00%); split: -0.00%, +0.00% Totals from 26 (0.00% of 805759) affected shaders: Instrs: 325629 -> 323210 (-0.74%); split: -0.74%, +0.00% Cycle count: 893896782 -> 892460178 (-0.16%); split: -0.21%, +0.05% Spill count: 10467 -> 10262 (-1.96%) Fill count: 24291 -> 24070 (-0.91%) Max live registers: 4946 -> 5021 (+1.52%); split: -0.08%, +1.60% Non SSA regs after NIR: 232980 -> 232978 (-0.00%); split: -0.03%, +0.03% Tiger Lake, Ice Lake, and Skylake had similar results. (Tiger Lake shown) Totals: Instrs: 237289818 -> 237289714 (-0.00%); split: -0.00%, +0.00% Cycle count: 22959586058 -> 22960049302 (+0.00%); split: -0.00%, +0.00% Max live registers: 42182257 -> 42182337 (+0.00%) Non SSA regs after NIR: 255579974 -> 255579970 (-0.00%); split: -0.00%, +0.00% Totals from 23 (0.00% of 802019) affected shaders: Instrs: 27051 -> 26947 (-0.38%); split: -0.39%, +0.01% Cycle count: 10545917 -> 11009161 (+4.39%); split: -0.09%, +4.49% Max live registers: 2198 -> 2278 (+3.64%) Non SSA regs after NIR: 31741 -> 31737 (-0.01%); split: -0.20%, +0.19% Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33648>
This commit is contained in:
parent
4311121e73
commit
3f39d8f4ff
1 changed files with 8 additions and 0 deletions
|
|
@ -1368,6 +1368,14 @@ optimizations.extend([
|
|||
(('uge', '#a', ('umax', '#b', c)), ('iand', ('uge', a, b), ('uge', a, c))),
|
||||
(('uge', ('umin', '#a', b), '#c'), ('iand', ('uge', a, c), ('uge', b, c))),
|
||||
|
||||
# These follow from the preceeding uge and ult patterns if various patterns
|
||||
# like uge(0, a) or ult(a, 1) are replaced with ieq or ine comparisons with
|
||||
# zero.
|
||||
(('ieq', ('umin', '#a', b), 0), ('ior', ('ieq', a, 0), ('ieq', b, 0))),
|
||||
(('ine', ('umax', '#a', b), 0), ('ior', ('ine', a, 0), ('ine', b, 0))),
|
||||
(('ieq', ('umax', '#a', b), 0), ('iand', ('ieq', a, 0), ('ieq', b, 0))),
|
||||
(('ine', ('umin', '#a', b), 0), ('iand', ('ine', a, 0), ('ine', b, 0))),
|
||||
|
||||
# Thanks to sign extension, the ishr(a, b) is negative if and only if a is
|
||||
# negative.
|
||||
(('bcsel', ('ilt', a, 0), ('ineg', ('ishr', a, b)), ('ishr', a, b)),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue