nir: Simplify fne(fneg(a), a) -> fne(a, 0.0)
authorThomas Helland <thomashelland90@gmail.com>
Thu, 6 Aug 2015 11:36:04 +0000 (13:36 +0200)
committerMatt Turner <mattst88@gmail.com>
Tue, 18 Aug 2015 18:34:44 +0000 (11:34 -0700)
commita39167d5949c76dfb48994caead4b59ab5f80318
tree4315cc93fbb82078da4295dd299643aff2e5bab1
parent29264d0d0cd5ca24314630d9dc22b3f971344a34
nir: Simplify fne(fneg(a), a) -> fne(a, 0.0)

-NaN != NaN, and -Inf != Inf, so this should be safe.
Found while working on my VRP pass.

Shader-db results on my IVB:
total instructions in shared programs: 1698267 -> 1698067 (-0.01%)
instructions in affected programs:     15785 -> 15585 (-1.27%)
helped:                                36
HURT:                                  0
GAINED:                                0
LOST:                                  0

Some shaders was found to have the following pattern in NIR:
vec1 ssa_26 = fneg ssa_21
vec1 ssa_27 = fne ssa_21, ssa_26

Make that:
vec1 ssa_27 = fne ssa_21, 0.0f

This is found in Dota2 and Brutal Legend.
One shader is cut by 8%, from 323 -> 296 instructons in SIMD8

Signed-off-by: Thomas Helland <thomashelland90@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir_opt_algebraic.py