nir/opt_algebraic: Optimize LLVM booleans

Helps OpenCL kernels.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25687>
This commit is contained in:
Alyssa Rosenzweig
2023-10-05 17:44:09 -04:00
committed by Marge Bot
parent c74a578c54
commit be0ab37bac

View File

@@ -1508,6 +1508,9 @@ optimizations.extend([
(('umax', ('b2i', 'a@1'), ('b2i', 'b@1')), ('b2i', ('ior', a, b))),
(('umin', ('b2i', 'a@1'), ('b2i', 'b@1')), ('b2i', ('iand', a, b))),
# Clean up LLVM booleans. b2i output is 0/1 so iand is a no-op.
(('iand', ('b2i', a), 1), ('b2i', a)),
(('ine', ('umin', ('ineg', ('b2i', 'a@1')), b), 0), ('iand', a, ('ine', b, 0))),
(('ine', ('umax', ('ineg', ('b2i', 'a@1')), b), 0), ('ior' , a, ('ine', b, 0))),