nir/algebraic: fix iabs(ishr(iabs(a), b)) optimization

iabs(a) is not positive if "a" is the minimum signed value, so this is
incorrect in that case for some values of "b".

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Fixes: 2b76de9b5d ("nir/algebraic: Add a couple optimizations for iabs and ishr")
(cherry picked from commit ecd6ae12fb)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32261>
This commit is contained in:
Rhys Perry
2024-11-15 15:03:03 +00:00
committed by Dylan Baker
parent b3cb911eff
commit 4af6a47426
2 changed files with 3 additions and 2 deletions

View File

@@ -1320,7 +1320,8 @@ optimizations.extend([
# negative.
(('bcsel', ('ilt', a, 0), ('ineg', ('ishr', a, b)), ('ishr', a, b)),
('iabs', ('ishr', a, b))),
(('iabs', ('ishr', ('iabs', a), b)), ('ishr', ('iabs', a), b)),
(('iabs', ('ishr', ('iabs', a), b)), ('ushr', ('iabs', a), b)),
(('iabs', ('ushr', ('iabs', a), b)), ('ushr', ('iabs', a), b)),
(('fabs', ('slt', a, b)), ('slt', a, b)),
(('fabs', ('sge', a, b)), ('sge', a, b)),