Mesa (main): nir: fix GCM when GVN enabled
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Aug 17 03:36:50 UTC 2021
Module: Mesa
Branch: main
Commit: edfcc4f0227322fd8f2d72fcf68c96e23b52ba01
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=edfcc4f0227322fd8f2d72fcf68c96e23b52ba01
Author: Timothy Arceri <tarceri at itsqueeze.com>
Date: Fri Aug 6 23:39:06 2021 +1000
nir: fix GCM when GVN enabled
Enabling GVN uncovered a bug where we would crash if the pass
thinking about pushing something into a loop.
Fixes: 6538b3e56614 ("nir: add heuristic for instructions in loops with GCM")
Acked-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12242>
---
src/compiler/nir/nir_opt_gcm.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c
index f7d46a701ee..853b630b224 100644
--- a/src/compiler/nir/nir_opt_gcm.c
+++ b/src/compiler/nir/nir_opt_gcm.c
@@ -395,6 +395,13 @@ static bool
set_block_for_loop_instr(struct gcm_state *state, nir_instr *instr,
nir_block *block)
{
+ /* If the instruction wasn't in a loop to begin with we don't want to push
+ * it down into one.
+ */
+ nir_loop *loop = state->blocks[instr->block->index].loop;
+ if (loop == NULL)
+ return true;
+
if (nir_block_dominates(instr->block, block))
return true;
@@ -402,7 +409,6 @@ set_block_for_loop_instr(struct gcm_state *state, nir_instr *instr,
* do{ ... break; } while(true)
* Don't move the instruction as it will not help anything.
*/
- nir_loop *loop = state->blocks[instr->block->index].loop;
if (loop->info->limiting_terminator == NULL && !loop->info->complex_loop &&
nir_block_ends_in_break(nir_loop_last_block(loop)))
return false;
More information about the mesa-commit
mailing list