nir/algebraic: Optimize some cases of (sXX(a, b) != 0.0)
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 1 Mar 2022 23:21:02 +0000 (15:21 -0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 3 Mar 2022 00:07:58 +0000 (00:07 +0000)
commit06eb9fb12599cf792f9bec36f5c5149258fde1dc
tree64a83ce505a8a29cc3153fcb1b8fd73b79b0f3ec
parent7d055c93e014d947b2b495450cd0968c32de6dd1
nir/algebraic: Optimize some cases of (sXX(a, b) != 0.0)

I noticed the SGE case while looking at the output of
shaders/closed/steam/trine-2/fp-3.shader_test on i915g.  These are
especially bad on i915 that needs two instructions to implement SNE.

An alternative would be to duplicate the sne(sXX(a, b), 0.0) rules in an
algebraic pass that occurs after bool_to_float.  Doing the work earlier
seems preferable.

i915
total instructions in shared programs: 788274 -> 788223 (<.01%)
instructions in affected programs: 666 -> 615 (-7.66%)
helped: 5
HURT: 0
helped stats (abs) min: 9 max: 12 x̄: 10.20 x̃: 9
helped stats (rel) min: 5.00% max: 11.11% x̄: 8.12% x̃: 8.16%
95% mean confidence interval for instructions value: -12.24 -8.16
95% mean confidence interval for instructions %-change: -10.81% -5.43%
Instructions are helped.

LOST:   0
GAINED: 2

The two gained shaders are assembly fragment programs in Euro Truck
Simulator 2.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15210>
src/compiler/nir/nir_opt_algebraic.py