nir/builder: Emit x != 0 for nir_i2b
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 15 Feb 2022 23:29:42 +0000 (15:29 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 14 Dec 2022 06:23:21 +0000 (06:23 +0000)
commit9342c14eeb4a751fce7bd413aca56bc46036ed22
tree5e5555ba7fb00435f22e23d79bb21433f8574df5
parent7a5e9df39db0e900135a88daf4b0ef15d54922c7
nir/builder: Emit x != 0 for nir_i2b

There are a lot of optimizations in opt_algebraic that match ('ine', a,
0), but there are almost none that match i2b.  Instead of adding a huge
pile of additional patterns (including variation that include both ine
and i2b), just emit a != 0 instead of i2b(a).

I think that the changes to the unit tests weaken them slightly, but
perhaps that's okay?

No shader-db changes on any Intel platform.  The GLSL paths use other
means to generate i2b operations, but the SPIR-V paths use nir_i2b.
Presumably since 4676b3d3dd9 (nir: Use nir_test_mask instead of
i2b(iand)), no fossil-db changes either.

v2: Use nir_ine_imm.  Suggested by Jesse.

Acked-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15121>
src/compiler/nir/nir_builder.h
src/compiler/nir/tests/load_store_vectorizer_tests.cpp