nir/dead_cf: delete code that's unreachable due to jumps
[mesa.git] / src / glsl / nir / nir_opt_gcm.c
index bf565b96988f65492bbff3dd77840a8fd938f65b..5b412eebc32df9fba71658f6fce100db386efbd3 100644 (file)
@@ -121,9 +121,11 @@ gcm_pin_instructions_block(nir_block *block, void *void_state)
          case nir_op_fddy_coarse:
             /* These can only go in uniform control flow; pin them for now */
             instr->pass_flags = GCM_INSTR_PINNED;
+            break;
 
          default:
             instr->pass_flags = 0;
+            break;
          }
          break;
 
@@ -134,9 +136,11 @@ gcm_pin_instructions_block(nir_block *block, void *void_state)
          case nir_texop_lod:
             /* These two take implicit derivatives so they need to be pinned */
             instr->pass_flags = GCM_INSTR_PINNED;
+            break;
 
          default:
             instr->pass_flags = 0;
+            break;
          }
          break;
 
@@ -252,7 +256,7 @@ gcm_schedule_early_instr(nir_instr *instr, struct gcm_state *state)
    /* Start with the instruction at the top.  As we iterate over the
     * sources, it will get moved down as needed.
     */
-   instr->block = state->impl->start_block;
+   instr->block = nir_start_block(state->impl);
    state->instr = instr;
 
    nir_foreach_src(instr, gcm_schedule_early_src, state);
@@ -275,9 +279,8 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
 
    nir_block *lca = NULL;
 
-   struct set_entry *entry;
-   set_foreach(def->uses, entry) {
-      nir_instr *use_instr = (nir_instr *)entry->key;
+   nir_foreach_use(def, use_src) {
+      nir_instr *use_instr = use_src->parent_instr;
 
       gcm_schedule_late_instr(use_instr, state);
 
@@ -300,8 +303,8 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
       }
    }
 
-   set_foreach(def->if_uses, entry) {
-      nir_if *if_stmt = (nir_if *)entry->key;
+   nir_foreach_if_use(def, use_src) {
+      nir_if *if_stmt = use_src->parent_if;
 
       /* For if statements, we consider the block to be the one immediately
        * preceding the if CF node.
@@ -373,9 +376,8 @@ gcm_place_instr(nir_instr *instr, struct gcm_state *state);
 static bool
 gcm_place_instr_def(nir_ssa_def *def, void *state)
 {
-   struct set_entry *entry;
-   set_foreach(def->uses, entry)
-      gcm_place_instr((nir_instr *)entry->key, state);
+   nir_foreach_use(def, use_src)
+      gcm_place_instr(use_src->parent_instr, state);
 
    return false;
 }