nir/algebraic: optimize bcsel(ieq(b, 0), a, shift(a, b))

nir_lower_mem_access_bit_sizes can create this.

No fossil-db changes.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31904>
This commit is contained in:
Rhys Perry 2024-09-27 17:33:05 +01:00 committed by Marge Bot
parent 80b76ba692
commit e95a3364b8

View file

@ -1508,6 +1508,12 @@ optimizations.extend([
(('ishr', a, 0), a),
(('ushr', 0, a), 0),
(('ushr', a, 0), a),
(('bcsel', ('ieq', b, 0), a, ('ushr', a, b)), ('ushr', a, b)),
(('bcsel', ('ieq', b, 0), a, ('ishr', a, b)), ('ishr', a, b)),
(('bcsel', ('ieq', b, 0), a, ('ishl', a, b)), ('ishl', a, b)),
(('bcsel', ('ine', b, 0), ('ushr', a, b), a), ('ushr', a, b)),
(('bcsel', ('ine', b, 0), ('ishr', a, b), a), ('ishr', a, b)),
(('bcsel', ('ine', b, 0), ('ishl', a, b), a), ('ishl', a, b)),
(('ior', ('ishl@16', a, b), ('ushr@16', a, ('iadd', 16, ('ineg', b)))), ('urol', a, b), 'options->has_rotate16'),
(('ior', ('ishl@16', a, b), ('ushr@16', a, ('isub', 16, b))), ('urol', a, b), 'options->has_rotate16'),
(('ior', ('ishl@32', a, b), ('ushr@32', a, ('iadd', 32, ('ineg', b)))), ('urol', a, b), 'options->has_rotate32'),