summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-01-21 23:52:17 -0800
committerKenneth Graunke <[email protected]>2015-01-23 14:53:26 -0800
commit15063d2ad0945004ef387511d0c805bbe734bc5f (patch)
tree08315aebf71d395a3bc5561a28f245ddd5854ed6 /src/glsl
parentbbd60f6d7916d5758ba1b8d49cb0c37c1543199e (diff)
nir: Add algebraic optimizations for division and reciprocal.
These also exist in opt_algebraic.cpp. total NIR instructions in shared programs: 2011430 -> 2011211 (-0.01%) NIR instructions in affected programs: 42221 -> 42002 (-0.52%) helped: 198 total i965 instructions in shared programs: 6020553 -> 6020116 (-0.01%) i965 instructions in affected programs: 84322 -> 83885 (-0.52%) helped: 394 HURT: 1 (by 1 instruction) Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/nir_opt_algebraic.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 42846e1202b..9c62b283634 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -106,6 +106,11 @@ optimizations = [
(('fpow', a, 1.0), a),
(('fpow', a, 2.0), ('fmul', a, a)),
(('fpow', 2.0, a), ('fexp2', a)),
+ # Division and reciprocal
+ (('fdiv', 1.0, a), ('frcp', a)),
+ (('frcp', ('frcp', a)), a),
+ (('frcp', ('fsqrt', a)), ('frsq', a)),
+ (('frcp', ('frsq', a)), ('fsqrt', a)),
# This one may not be exact
(('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),