From b35e8a38e76d42430dd45b06f0e60be2e39a6e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 13 Jul 2025 05:56:34 -0400 Subject: [PATCH] nir/opt_move_to_top: check can_reorder & can_speculate No effect now, but may be needed in the future. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_opt_move_to_top.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compiler/nir/nir_opt_move_to_top.c b/src/compiler/nir/nir_opt_move_to_top.c index fe48ef73949..81dd891385c 100644 --- a/src/compiler/nir/nir_opt_move_to_top.c +++ b/src/compiler/nir/nir_opt_move_to_top.c @@ -80,6 +80,18 @@ can_move_src_to_top(nir_src *src, void *_state) instr->pass_flags |= PASS_FLAG_CANT_MOVE; return false; } + + if (instr->block == nir_start_block(state->impl) && + !nir_intrinsic_can_reorder(nir_instr_as_intrinsic(instr))) { + instr->pass_flags |= PASS_FLAG_CANT_MOVE; + return false; + } + } + + if (instr->block != nir_start_block(state->impl) && + !nir_instr_can_speculate(instr)) { + instr->pass_flags |= PASS_FLAG_CANT_MOVE; + return false; } if (!nir_foreach_src(instr, can_move_src_to_top, state)) {