i965: Move must_use/has_separate_stencil fields to brw_context.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vec4_copy_propagation.cpp
index 51ee47504900d22cc8a6ea20ebb7162e1ee46503..c28d0dee2d82b94d993cf18f59f641effcc6b600 100644 (file)
@@ -95,6 +95,7 @@ try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4])
       inst->src[arg] = value;
       return true;
 
+   case BRW_OPCODE_MACH:
    case BRW_OPCODE_MUL:
    case BRW_OPCODE_ADD:
       if (arg == 1) {
@@ -102,9 +103,10 @@ try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4])
         return true;
       } else if (arg == 0 && inst->src[1].file != IMM) {
         /* Fit this constant in by commuting the operands.  Exception: we
-         * can't do this for 32-bit integer MUL because it's asymmetric.
+         * can't do this for 32-bit integer MUL/MACH because it's asymmetric.
          */
-        if (inst->opcode == BRW_OPCODE_MUL &&
+        if ((inst->opcode == BRW_OPCODE_MUL ||
+              inst->opcode == BRW_OPCODE_MACH) &&
             (inst->src[1].type == BRW_REGISTER_TYPE_D ||
              inst->src[1].type == BRW_REGISTER_TYPE_UD))
            break;
@@ -160,8 +162,7 @@ try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4])
 }
 
 bool
-vec4_visitor::try_copy_propagation(struct intel_context *intel,
-                                   vec4_instruction *inst, int arg,
+vec4_visitor::try_copy_propagation(vec4_instruction *inst, int arg,
                                    src_reg *values[4])
 {
    /* For constant propagation, we only handle the same constant
@@ -215,6 +216,13 @@ vec4_visitor::try_copy_propagation(struct intel_context *intel,
    if (has_source_modifiers && !can_do_source_mods(inst))
       return false;
 
+   bool is_3src_inst = (inst->opcode == BRW_OPCODE_LRP ||
+                        inst->opcode == BRW_OPCODE_MAD ||
+                        inst->opcode == BRW_OPCODE_BFE ||
+                        inst->opcode == BRW_OPCODE_BFI2);
+   if (is_3src_inst && value.file == UNIFORM)
+      return false;
+
    /* We can't copy-propagate a UD negation into a condmod
     * instruction, because the condmod ends up looking at the 33-bit
     * signed accumulator value instead of the 32-bit value we wanted
@@ -297,7 +305,7 @@ vec4_visitor::opt_copy_propagation()
            continue;
 
         if (try_constant_propagation(inst, i, values) ||
-            try_copy_propagation(intel, inst, i, values))
+            try_copy_propagation(inst, i, values))
            progress = true;
       }