Mesa (master): i965/vec4: Allow reswizzling writemasks when swizzle is single-valued.

Matt Turner mattst88 at kemper.freedesktop.org
Wed Aug 20 20:00:59 UTC 2014


Module: Mesa
Branch: master
Commit: 04895f5c601b240df547739da786b7c2b65bdd1e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=04895f5c601b240df547739da786b7c2b65bdd1e

Author: Matt Turner <mattst88 at gmail.com>
Date:   Fri Aug 15 12:32:23 2014 -0700

i965/vec4: Allow reswizzling writemasks when swizzle is single-valued.

total instructions in shared programs: 4288033 -> 4266151 (-0.51%)
instructions in affected programs:     930915 -> 909033 (-2.35%)

---

 src/mesa/drivers/dri/i965/brw_vec4.cpp |   60 ++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 27 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 5477fe6..ee61202 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -944,24 +944,27 @@ vec4_instruction::can_reswizzle_dst(int dst_writemask,
       return false;
 
    switch (opcode) {
-   case BRW_OPCODE_DP4:
-   case BRW_OPCODE_DP3:
-   case BRW_OPCODE_DP2:
-      return true;
    default:
-      /* Check if there happens to be no reswizzling required. */
-      for (int c = 0; c < 4; c++) {
-         int bit = 1 << BRW_GET_SWZ(swizzle, c);
-         /* Skip components of the swizzle not used by the dst. */
-         if (!(dst_writemask & (1 << c)))
-            continue;
+      if (!brw_is_single_value_swizzle(swizzle)) {
+         /* Check if there happens to be no reswizzling required. */
+         for (int c = 0; c < 4; c++) {
+            int bit = 1 << BRW_GET_SWZ(swizzle, c);
+            /* Skip components of the swizzle not used by the dst. */
+            if (!(dst_writemask & (1 << c)))
+               continue;
 
-         /* We don't do the reswizzling yet, so just sanity check that we
-          * don't have to.
-          */
-         if (bit != (1 << c))
-            return false;
+            /* We don't do the reswizzling yet, so just sanity check that we
+             * don't have to.
+             */
+            if (bit != (1 << c))
+               return false;
+         }
+         return true;
       }
+      /* fallthrough */
+   case BRW_OPCODE_DP4:
+   case BRW_OPCODE_DP3:
+   case BRW_OPCODE_DP2:
       return true;
    }
 }
@@ -979,6 +982,21 @@ vec4_instruction::reswizzle_dst(int dst_writemask, int swizzle)
    int new_writemask = 0;
 
    switch (opcode) {
+   default:
+      if (!brw_is_single_value_swizzle(swizzle)) {
+         for (int c = 0; c < 4; c++) {
+            /* Skip components of the swizzle not used by the dst. */
+            if (!(dst_writemask & (1 << c)))
+               continue;
+
+            /* We don't do the reswizzling yet, so just sanity check that we
+             * don't have to.
+             */
+            assert((1 << BRW_GET_SWZ(swizzle, c)) == (1 << c));
+         }
+         break;
+      }
+      /* fallthrough */
    case BRW_OPCODE_DP4:
    case BRW_OPCODE_DP3:
    case BRW_OPCODE_DP2:
@@ -995,18 +1013,6 @@ vec4_instruction::reswizzle_dst(int dst_writemask, int swizzle)
       }
       dst.writemask = new_writemask;
       break;
-   default:
-      for (int c = 0; c < 4; c++) {
-         /* Skip components of the swizzle not used by the dst. */
-         if (!(dst_writemask & (1 << c)))
-            continue;
-
-         /* We don't do the reswizzling yet, so just sanity check that we
-          * don't have to.
-          */
-         assert((1 << BRW_GET_SWZ(swizzle, c)) == (1 << c));
-      }
-      break;
    }
 }
 




More information about the mesa-commit mailing list