Mesa (staging/22.0): nir: Handle register sources in lower_phis_to_regs_block
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 20:58:20 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: 0392fcf3c43e260a71f92a9030a82a5175cfc9f4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0392fcf3c43e260a71f92a9030a82a5175cfc9f4
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Fri Apr 22 16:37:37 2022 -0500
nir: Handle register sources in lower_phis_to_regs_block
During certain control-flow manipulation passes, we go out-of-SSA
temporarily in certain areas of the code to make control-flow
manipulation easier. This can result in registers being in phi sources
temporarily. If two sub-passes run before we get a chance to do
clean-up, we can end up doing some out-of-SSA and then a bit more
out-of-SSA and trigger this case. It's easy enough to handle.
Fixes: a620f66872c2 ("nir: Add a couple quick-and-dirty out-of-SSA helpers")
Fixes: 79a987ad2a1e ("nir/opt_if: also merge break statements with ones after the branch")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6370
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16111>
(cherry picked from commit 4a4d6cdc80bb4e153bf263d1fed919a5026cff2a)
---
.pick_status.json | 2 +-
src/compiler/nir/nir_from_ssa.c | 14 ++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index d8c5793bdf3..3de34717359 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -836,7 +836,7 @@
"description": "nir: Handle register sources in lower_phis_to_regs_block",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"because_sha": "a620f66872c27fa24a1ccdd1d0a6e563eefbaad6"
},
{
diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c
index 707e670cc15..9ad45cb1a8c 100644
--- a/src/compiler/nir/nir_from_ssa.c
+++ b/src/compiler/nir/nir_from_ssa.c
@@ -1006,10 +1006,16 @@ nir_lower_phis_to_regs_block(nir_block *block)
nir_ssa_def_rewrite_uses(&phi->dest.ssa, def);
nir_foreach_phi_src(src, phi) {
- assert(src->src.is_ssa);
- _mesa_set_add(visited_blocks, src->src.ssa->parent_instr->block);
- place_phi_read(&b, reg, src->src.ssa, src->pred, visited_blocks);
- _mesa_set_clear(visited_blocks, NULL);
+ if (src->src.is_ssa) {
+ _mesa_set_add(visited_blocks, src->src.ssa->parent_instr->block);
+ place_phi_read(&b, reg, src->src.ssa, src->pred, visited_blocks);
+ _mesa_set_clear(visited_blocks, NULL);
+ } else {
+ b.cursor = nir_after_block_before_jump(src->pred);
+ nir_ssa_def *src_ssa =
+ nir_ssa_for_src(&b, src->src, phi->dest.ssa.num_components);
+ nir_store_reg(&b, reg, src_ssa, ~0);
+ }
}
nir_instr_remove(&phi->instr);
More information about the mesa-commit
mailing list