Module: Mesa Branch: main Commit: be0ab37bacbc782576d05309dcfe2323b27d24b7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be0ab37bacbc782576d05309dcfe2323b27d24b7
Author: Alyssa Rosenzweig <[email protected]> Date: Thu Oct 5 17:44:09 2023 -0400 nir/opt_algebraic: Optimize LLVM booleans Helps OpenCL kernels. Signed-off-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25687> --- src/compiler/nir/nir_opt_algebraic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 22a1859ef48..48aa97223e4 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -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))),
