nir: save IO semantics in lowered IO intrinsics
[mesa.git] / src / compiler / nir / nir_opt_copy_propagate.c
index 10b81c0a68435857ec2082cc5e84221fdf2de40b..2f7e4bc49f747f828ac3a7a993d93a67bfbabec1 100644 (file)
@@ -26,7 +26,6 @@
  */
 
 #include "nir.h"
-#include <main/imports.h>
 
 /**
  * SSA-based copy propagation
@@ -36,8 +35,7 @@ static bool is_move(nir_alu_instr *instr)
 {
    assert(instr->src[0].src.is_ssa);
 
-   if (instr->op != nir_op_fmov &&
-       instr->op != nir_op_imov)
+   if (instr->op != nir_op_mov)
       return false;
 
    if (instr->dest.saturate)
@@ -62,9 +60,8 @@ static bool is_vec(nir_alu_instr *instr)
          return false;
    }
 
-   return instr->op == nir_op_vec2 ||
-          instr->op == nir_op_vec3 ||
-          instr->op == nir_op_vec4;
+   assert(instr->dest.dest.is_ssa);
+   return nir_op_is_vec(instr->op);
 }
 
 static bool
@@ -142,17 +139,16 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, unsigned index)
       return false;
 
    nir_ssa_def *def;
-   unsigned new_swizzle[4] = {0, 0, 0, 0};
+   unsigned new_swizzle[NIR_MAX_VEC_COMPONENTS] = {0, 0, 0, 0};
 
-   if (alu_instr->op == nir_op_fmov ||
-       alu_instr->op == nir_op_imov) {
-      for (unsigned i = 0; i < 4; i++)
+   if (alu_instr->op == nir_op_mov) {
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
          new_swizzle[i] = alu_instr->src[0].swizzle[src->swizzle[i]];
       def = alu_instr->src[0].src.ssa;
    } else {
       def = NULL;
 
-      for (unsigned i = 0; i < 4; i++) {
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {
          if (!nir_alu_instr_channel_used(parent_alu_instr, index, i))
             continue;
 
@@ -167,7 +163,7 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, unsigned index)
       }
    }
 
-   for (unsigned i = 0; i < 4; i++)
+   for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
       src->swizzle[i] = new_swizzle[i];
 
    nir_instr_rewrite_src(&parent_alu_instr->instr, &src->src,
@@ -277,9 +273,7 @@ nir_copy_prop_impl(nir_function_impl *impl)
       nir_metadata_preserve(impl, nir_metadata_block_index |
                                   nir_metadata_dominance);
    } else {
-#ifndef NDEBUG
-      impl->valid_metadata &= ~nir_metadata_not_properly_reset;
-#endif
+      nir_metadata_preserve(impl, nir_metadata_all);
    }
 
    return progress;