i915g: More ops commute.
[mesa.git] / src / gallium / drivers / i915 / i915_fpc_optimize.c
index b09f18b01ee174d6ff5baa80265b3adf03489005..ce1c5f9830187197335c558d571068361ecfa3de 100644 (file)
@@ -87,17 +87,30 @@ static boolean is_unswizzled(struct i915_full_src_register* r,
 
 static boolean op_commutes(unsigned opcode)
 {
-   if (opcode == TGSI_OPCODE_ADD) return TRUE;
-   if (opcode == TGSI_OPCODE_MUL) return TRUE;
+   switch(opcode)
+   {
+      case TGSI_OPCODE_ADD:
+      case TGSI_OPCODE_MUL:
+      case TGSI_OPCODE_DP2:
+      case TGSI_OPCODE_DP3:
+      case TGSI_OPCODE_DP4:
+         return TRUE;
+   }
    return FALSE;
 }
 
 static unsigned op_neutral_element(unsigned opcode)
 {
-   if (opcode == TGSI_OPCODE_ADD)
-      return TGSI_SWIZZLE_ZERO;
-   if (opcode == TGSI_OPCODE_MUL)
-      return TGSI_SWIZZLE_ONE;
+   switch(opcode)
+   {
+      case TGSI_OPCODE_ADD:
+         return TGSI_SWIZZLE_ZERO;
+      case TGSI_OPCODE_MUL:
+      case TGSI_OPCODE_DP2:
+      case TGSI_OPCODE_DP3:
+      case TGSI_OPCODE_DP4:
+         return TGSI_SWIZZLE_ONE;
+   }
 
    debug_printf("Unknown opcode %d\n",opcode);
    return TGSI_SWIZZLE_ZERO;