nir/opt_algebraic: Optimize more (a cmp b ? a : b) to min/max.

Foz-DB Navi21:
Totals from 112 (0.08% of 134913) affected shaders:
CodeSize: 1618384 -> 1618172 (-0.01%); split: -0.06%, +0.04%
Instrs: 307695 -> 307535 (-0.05%); split: -0.05%, +0.00%
Latency: 3590228 -> 3589658 (-0.02%); split: -0.02%, +0.00%
InvThroughput: 563692 -> 563447 (-0.04%); split: -0.05%, +0.01%
Copies: 24541 -> 24519 (-0.09%); split: -0.10%, +0.01%
Branches: 13480 -> 13468 (-0.09%)

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18548>
This commit is contained in:
Georg Lehmann
2022-09-12 13:12:18 +02:00
committed by Marge Bot
parent d0d90b4de9
commit bfb12a3b6a

View File

@@ -700,6 +700,14 @@ optimizations.extend([
(('~bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
(('~bcsel', ('fge', a, b), b, a), ('fmin', a, b)),
(('~bcsel', ('fge', b, a), b, a), ('fmax', a, b)),
(('bcsel', ('ult', b, a), b, a), ('umin', a, b)),
(('bcsel', ('ult', a, b), b, a), ('umax', a, b)),
(('bcsel', ('uge', a, b), b, a), ('umin', a, b)),
(('bcsel', ('uge', b, a), b, a), ('umax', a, b)),
(('bcsel', ('ilt', b, a), b, a), ('imin', a, b)),
(('bcsel', ('ilt', a, b), b, a), ('imax', a, b)),
(('bcsel', ('ige', a, b), b, a), ('imin', a, b)),
(('bcsel', ('ige', b, a), b, a), ('imax', a, b)),
(('bcsel', ('i2b', a), b, c), ('bcsel', ('ine', a, 0), b, c)),
(('bcsel', ('inot', a), b, c), ('bcsel', a, c, b)),
(('bcsel', a, ('bcsel', a, b, c), d), ('bcsel', a, b, d)),