nir: add min/max optimisation
authorElie TOURNIER <tournier.elie@gmail.com>
Wed, 18 Jan 2017 11:23:22 +0000 (11:23 +0000)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 20 Jan 2017 05:44:28 +0000 (21:44 -0800)
commit9fdaeb7776c51e45646502ce4b6420a9652cd824
tree2aba551c9da0875a707430be9db3c8826120a8c8
parentf22ee14644143b5edeed7f345b93fb361c16c71b
nir: add min/max optimisation

Add the following optimisations:

min(x, -x) = -abs(x)
min(x, -abs(x)) = -abs(x)
min(x, abs(x)) = x
max(x, -abs(x)) = x
max(x, abs(x)) = abs(x)
max(x, -x) = abs(x)

shader-db:

total instructions in shared programs: 13067779 -> 13067775 (-0.00%)
instructions in affected programs: 249 -> 245 (-1.61%)
helped: 4
HURT: 0

total cycles in shared programs: 252054838 -> 252054806 (-0.00%)
cycles in affected programs: 504 -> 472 (-6.35%)
helped: 2
HURT: 0

Signed-off-by: Elie Tournier <tournier.elie@gmail.com>
Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_opt_algebraic.py