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")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32157>
This commit is contained in:
Rhys Perry
2024-11-15 15:03:03 +00:00
committed by Marge Bot
parent 217d70fc38
commit ecd6ae12fb
+2 -1
View File
@@ -1327,7 +1327,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)),