nir/algebraic: Optimize some ifind_msb to ufind_msb
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 10 Oct 2022 20:42:56 +0000 (13:42 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 10 Mar 2023 15:27:17 +0000 (15:27 +0000)
commit831f9d3f615ca5228e9614191d76f95735bfc2cc
tree4e4086490beb62ba658451f25b65527510520e85
parentdb6d1edc1b614540d0c558571d5b0b09f7d8adef
nir/algebraic: Optimize some ifind_msb to ufind_msb

On Intel platforms, the uclz lowering if ufind_msb is either one
instruction better (Gfx7 and newer) or two instructions better (all
older platforms) than the ifind_msb implementations.

On platforms that use lower_find_msb_to_reverse, there should be no
difference.

All Haswell and newer Intel platforms had similar results. (Ice Lake shown)
total instructions in shared programs: 19938662 -> 19938634 (<.01%)
instructions in affected programs: 850 -> 822 (-3.29%)
helped: 2 / HURT: 0

total cycles in shared programs: 858467067 -> 858465538 (<.01%)
cycles in affected programs: 10080 -> 8551 (-15.17%)
helped: 2 / HURT: 0

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19042>
src/compiler/nir/nir_opt_algebraic.py