nir/opt_undef: Handle a couple more normal store intrinsics.
[mesa.git] / src / compiler / nir / nir_opt_undef.c
index 428a1f26599a146c34455f7b27b248a46949605a..e03e5b88efc6bb2629fddcd63c2b799f05d58291 100644 (file)
@@ -63,7 +63,7 @@ opt_undef_csel(nir_alu_instr *instr)
       memset(&empty_src, 0, sizeof(empty_src));
       nir_instr_rewrite_src(&instr->instr, &instr->src[1].src, empty_src);
       nir_instr_rewrite_src(&instr->instr, &instr->src[2].src, empty_src);
-      instr->op = nir_op_imov;
+      instr->op = nir_op_mov;
 
       return true;
    }
@@ -77,11 +77,7 @@ opt_undef_csel(nir_alu_instr *instr)
 static bool
 opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
 {
-   if (alu->op != nir_op_vec2 &&
-       alu->op != nir_op_vec3 &&
-       alu->op != nir_op_vec4 &&
-       alu->op != nir_op_fmov &&
-       alu->op != nir_op_imov)
+   if (!nir_op_is_vec(alu->op))
       return false;
 
    assert(alu->dest.dest.is_ssa);
@@ -116,6 +112,8 @@ opt_undef_store(nir_intrinsic_instr *intrin)
    case nir_intrinsic_store_per_vertex_output:
    case nir_intrinsic_store_ssbo:
    case nir_intrinsic_store_shared:
+   case nir_intrinsic_store_global:
+   case nir_intrinsic_store_scratch:
       arg_index =  0;
       break;
    default:
@@ -137,8 +135,6 @@ nir_opt_undef(nir_shader *shader)
    nir_builder b;
    bool progress = false;
 
-   nir_assert_unlowered_derefs(shader, nir_lower_load_store_derefs);
-
    nir_foreach_function(function, shader) {
       if (function->impl) {
          nir_builder_init(&b, function->impl);
@@ -156,10 +152,13 @@ nir_opt_undef(nir_shader *shader)
             }
          }
 
-         if (progress)
+         if (progress) {
             nir_metadata_preserve(function->impl,
                                   nir_metadata_block_index |
                                   nir_metadata_dominance);
+         } else {
+            nir_metadata_preserve(function->impl, nir_metadata_all);
+         }
       }
    }