Mesa (master): nir/lcssa: consider loops with no back-edge invariant
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Nov 6 16:07:50 UTC 2020
Module: Mesa
Branch: master
Commit: f0a88dbefa640ddee10b475bdf01b050d998c91c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f0a88dbefa640ddee10b475bdf01b050d998c91c
Author: Daniel Schürmann <daniel at schuermann.dev>
Date: Fri Jul 10 13:37:36 2020 +0200
nir/lcssa: consider loops with no back-edge invariant
Polaris:
Totals from 6233 (4.52% of 138014) affected shaders:
SpillSGPRs: 47860 -> 48976 (+2.33%)
CodeSize: 69764704 -> 69120700 (-0.92%); split: -0.97%, +0.04%
Instrs: 13801184 -> 13594107 (-1.50%)
Cycles: 1628800928 -> 1516137888 (-6.92%)
VMEM: 910459 -> 910208 (-0.03%); split: +0.00%, -0.03%
SMEM: 436625 -> 435194 (-0.33%); split: +0.06%, -0.38%
SClause: 534750 -> 534620 (-0.02%); split: -0.03%, +0.00%
Copies: 1587121 -> 1542867 (-2.79%); split: -2.81%, +0.03%
Branches: 545016 -> 509354 (-6.54%)
PreSGPRs: 618545 -> 619354 (+0.13%); split: -0.09%, +0.22%
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5924>
---
src/compiler/nir/nir_to_lcssa.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_to_lcssa.c b/src/compiler/nir/nir_to_lcssa.c
index 527cdca4120..345879acf4f 100644
--- a/src/compiler/nir/nir_to_lcssa.c
+++ b/src/compiler/nir/nir_to_lcssa.c
@@ -313,8 +313,18 @@ convert_to_lcssa(nir_cf_node *cf_node, lcssa_state *state)
foreach_list_typed(nir_cf_node, nested_node, node, &loop->body)
convert_to_lcssa(nested_node, state);
+ state->loop = loop;
+
/* mark loop-invariant instructions */
if (state->skip_invariants) {
+ /* Without a loop all instructions are invariant.
+ * For outer loops, multiple breaks can still create phis.
+ * The variance then depends on all (nested) break conditions.
+ * We don't consider this, but assume all not_invariant.
+ */
+ if (nir_loop_first_block(loop)->predecessors->entries == 1)
+ goto end;
+
nir_foreach_block_in_cf_node(block, cf_node) {
nir_foreach_instr(instr, block) {
if (instr->pass_flags == undefined)
@@ -323,7 +333,6 @@ convert_to_lcssa(nir_cf_node *cf_node, lcssa_state *state)
}
}
- state->loop = loop;
nir_foreach_block_in_cf_node(block, cf_node) {
nir_foreach_instr(instr, block) {
nir_foreach_ssa_def(instr, convert_loop_exit_for_ssa, state);
@@ -334,6 +343,7 @@ convert_to_lcssa(nir_cf_node *cf_node, lcssa_state *state)
}
}
+end:
/* For outer loops, the LCSSA-phi should be considered not invariant */
if (state->skip_invariants) {
nir_block *block_after_loop =
More information about the mesa-commit
mailing list