nir: add nir_var_shader_storage
[mesa.git] / src / glsl / nir / nir_opt_peephole_select.c
index f400cfd66da3ecf4e6656a593f2056922f78b95b..6620e5dc81f4b58fcb43eb87435b8fa86da44904 100644 (file)
@@ -82,12 +82,22 @@ block_check_for_allowed_instrs(nir_block *block)
          break;
 
       case nir_instr_type_alu: {
-         /* It must be a move operation */
          nir_alu_instr *mov = nir_instr_as_alu(instr);
-         if (mov->op != nir_op_fmov && mov->op != nir_op_imov &&
-             mov->op != nir_op_fneg && mov->op != nir_op_ineg &&
-             mov->op != nir_op_fabs && mov->op != nir_op_iabs)
+         switch (mov->op) {
+         case nir_op_fmov:
+         case nir_op_imov:
+         case nir_op_fneg:
+         case nir_op_ineg:
+         case nir_op_fabs:
+         case nir_op_iabs:
+         case nir_op_vec2:
+         case nir_op_vec3:
+         case nir_op_vec4:
+            /* It must be a move-like operation. */
+            break;
+         default:
             return false;
+         }
 
          /* Can't handle saturate */
          if (mov->dest.saturate)
@@ -98,15 +108,13 @@ block_check_for_allowed_instrs(nir_block *block)
             return false;
 
          /* It cannot have any if-uses */
-         if (mov->dest.dest.ssa.if_uses->entries != 0)
+         if (!list_empty(&mov->dest.dest.ssa.if_uses))
             return false;
 
          /* The only uses of this definition must be phi's in the successor */
-         struct set_entry *entry;
-         set_foreach(mov->dest.dest.ssa.uses, entry) {
-            const nir_instr *dest_instr = entry->key;
-            if (dest_instr->type != nir_instr_type_phi ||
-                dest_instr->block != block->successors[0])
+         nir_foreach_use(&mov->dest.dest.ssa, use) {
+            if (use->parent_instr->type != nir_instr_type_phi ||
+                use->parent_instr->block != block->successors[0])
                return false;
          }
          break;