nir/gcm: Prefer the instruction's original block
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 18 Jan 2017 02:38:41 +0000 (18:38 -0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 20 Apr 2020 03:46:29 +0000 (03:46 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4636>

src/compiler/nir/nir_opt_gcm.c

index 86432ab1ab58b9e0ef300305babec57d9a4deaba..bdd1c7d205635c195c6fdea4e42e5422ccc98619 100644 (file)
@@ -279,6 +279,8 @@ gcm_choose_block_for_instr(nir_instr *instr, nir_block *early_block,
       if (state->blocks[block->index].loop_depth <
           state->blocks[best->index].loop_depth)
          best = block;
+      else if (block == instr->block)
+         best = block;
 
       if (block == early_block)
          break;