nir/copy_propagate: Don't cause size mismatches on phi node sources
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 25 Nov 2014 06:42:16 +0000 (22:42 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Jan 2015 15:19:02 +0000 (07:19 -0800)
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/glsl/nir/nir_opt_copy_propagate.c

index a2be047a65895f59af87d80465def251626a3e13..2feebe42c00f61ee89fd68a98362799dd69825a6 100644 (file)
@@ -157,6 +157,18 @@ copy_prop_src(nir_src *src, nir_instr *parent_instr, nir_if *parent_if)
    if (!is_swizzleless_move(alu_instr))
       return false;
 
+   /* Don't let copy propagation land us with a phi that has more
+    * components in its source than it has in its destination.  That badly
+    * messes up out-of-ssa.
+    */
+   if (parent_instr && parent_instr->type == nir_instr_type_phi) {
+      nir_phi_instr *phi = nir_instr_as_phi(parent_instr);
+      assert(phi->dest.is_ssa);
+      if (phi->dest.ssa.num_components !=
+          alu_instr->src[0].src.ssa->num_components)
+         return false;
+   }
+
    if (parent_instr)
       rewrite_src_instr(src, alu_instr->src[0].src.ssa, parent_instr);
    else