nir: Add algebraic optimizations for simplifying comparisons.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 22 Jan 2015 07:36:01 +0000 (23:36 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 23 Jan 2015 22:53:26 +0000 (14:53 -0800)
commit391fb32bbef3bdeb7bab78a4d3c5317a0153381e
tree2d2f3bfdee9a8c6b5703e01a8e83cb0980d07baa
parent551a752a592703a97dcee74765463bb15ccb8b14
nir: Add algebraic optimizations for simplifying comparisons.

The first batch removes bonus fnot/inot operations, possibly allowing
other optimizations to better recognize patterns.

The next batch replaces a fadd and constant 0.0 with an fneg - negation
is usually free on GPUs, while addition is not.

total NIR instructions in shared programs: 2020814 -> 2015593 (-0.26%)
NIR instructions in affected programs:     411143 -> 405922 (-1.27%)
helped:                                    2233
HURT:                                      214

A few shaders are hurt by a few instructions due to moving neg such
that it has a constant operand, which is then folded, resulting in two
distinct load_consts for x and -x.  We can always clean that up later.

total i965 instructions in shared programs: 6035392 -> 6025505 (-0.16%)
i965 instructions in affected programs:     784980 -> 775093 (-1.26%)
helped:                                     4508
HURT:                                       2

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir_opt_algebraic.py