nir/algebraic: optimize bits=umin(bits, 32-(offset&0x1f))
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 6 Oct 2021 14:06:51 +0000 (15:06 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Sep 2022 20:36:06 +0000 (20:36 +0000)
commitc23411a970144a51b3ddffb1e97d46bb3b3ca362
tree1a3edf80a9c70d7af3b6a4b289cf48ef2a5ddc1c
parent07a520f73168b1ee49e4baa68751b4e5a4c0d6ab
nir/algebraic: optimize bits=umin(bits, 32-(offset&0x1f))

Optimizes patterns which are created by recent versions of vkd3d-proton,
when constant folding doesn't eliminate it entirely:
- ubitfield_extract(value, offset, umin(bits, 32-(offset&0x1f)))
- ibitfield_extract(value, offset, umin(bits, 32-(offset&0x1f)))
- bitfield_insert(base, insert, offset, umin(bits, 32-(offset&0x1f)))

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13225>
src/compiler/nir/nir_opt_algebraic.py
src/compiler/nir/nir_search_helpers.h