summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-01-03 22:54:48 +1100
committerTimothy Arceri <[email protected]>2017-01-12 09:47:29 +1100
commit7acc8652268205a266068ea4d059eccce43e1f78 (patch)
tree856f2a3d0ab276f3fac769d582b50776a9be41bd /src
parent8f37fc70669024040c954f8a74e9d7b209c867d7 (diff)
nir: add late opt to turn inot/b2f combos back to bcsel
We turn these from bcsel into inot/b2f combos in order for other optimisation passes to get further. Once we have finished turn the ones that remain and are used in more than a single expression back into a bcsel. On BDW: total instructions in shared programs: 13060965 -> 13060297 (-0.01%) instructions in affected programs: 835701 -> 835033 (-0.08%) helped: 670 HURT: 2 total cycles in shared programs: 256599536 -> 256598006 (-0.00%) cycles in affected programs: 114655488 -> 114653958 (-0.00%) helped: 419 HURT: 240 LOST: 0 GAINED: 1 The 2 HURT is because inserting bcsel creates the only use of const 1.0 in two shaders from tri-of-friendship-and-madness. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py3
-rw-r--r--src/compiler/nir/nir_search_helpers.h16
2 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 57e386279cd..1852a4d53f3 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -519,6 +519,9 @@ late_optimizations = [
(('fdot3', a, b), ('fdot_replicated3', a, b), 'options->fdot_replicates'),
(('fdot4', a, b), ('fdot_replicated4', a, b), 'options->fdot_replicates'),
(('fdph', a, b), ('fdph_replicated', a, b), 'options->fdot_replicates'),
+
+ (('b2f(is_used_more_than_once)', ('inot', a)), ('bcsel', a, 0.0, 1.0)),
+ (('fneg(is_used_more_than_once)', ('b2f', ('inot', a))), ('bcsel', a, -0.0, -1.0)),
]
print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()
diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h
index 20fdae66e2c..ebb77ae67aa 100644
--- a/src/compiler/nir/nir_search_helpers.h
+++ b/src/compiler/nir/nir_search_helpers.h
@@ -114,4 +114,20 @@ is_zero_to_one(nir_alu_instr *instr, unsigned src, unsigned num_components,
return true;
}
+static inline bool
+is_used_more_than_once(nir_alu_instr *instr)
+{
+ bool zero_if_use = list_empty(&instr->dest.dest.ssa.if_uses);
+ bool zero_use = list_empty(&instr->dest.dest.ssa.uses);
+
+ if (zero_use && zero_if_use)
+ return false;
+ else if (zero_use && list_is_singular(&instr->dest.dest.ssa.if_uses))
+ return false;
+ else if (zero_if_use && list_is_singular(&instr->dest.dest.ssa.uses))
+ return false;
+
+ return true;
+}
+
#endif /* _NIR_SEARCH_ */