Mesa (master): gallivm: Altivec pack/unpack intrisics

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Nov 29 11:54:45 UTC 2012


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

Author: Adhemerval Zanella <azanella at linux.vnet.ibm.com>
Date:   Thu Nov 22 10:54:45 2012 -0600

gallivm: Altivec pack/unpack intrisics

This patch adds PPC Altivec support for pack/unpack operations using Altivec
supported vector type (8xi8, 16xi16, 4xi32, 4xf32).

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_pack.c |   44 ++++++++++++++++++--------
 1 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
index b467d56..f46c080 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
@@ -433,30 +433,46 @@ lp_build_pack2(struct gallivm_state *gallivm,
    assert(src_type.length * 2 == dst_type.length);
 
    /* Check for special cases first */
-   if(util_cpu_caps.has_sse2 && src_type.width * src_type.length >= 128) {
+   if((util_cpu_caps.has_sse2 || util_cpu_caps.has_altivec) &&
+       src_type.width * src_type.length >= 128) {
       const char *intrinsic = NULL;
 
       switch(src_type.width) {
       case 32:
-         if(dst_type.sign) {
-            intrinsic = "llvm.x86.sse2.packssdw.128";
-         }
-         else {
-            if (util_cpu_caps.has_sse4_1) {
-               intrinsic = "llvm.x86.sse41.packusdw";
+         if (util_cpu_caps.has_sse2) {
+           if(dst_type.sign) {
+              intrinsic = "llvm.x86.sse2.packssdw.128";
+           }
+           else {
+              if (util_cpu_caps.has_sse4_1) {
+                 intrinsic = "llvm.x86.sse41.packusdw";
 #if HAVE_LLVM < 0x0207
-               /* llvm < 2.7 has inconsistent signatures except for packusdw */
-               intr_type = dst_type;
+                 /* llvm < 2.7 has inconsistent signatures except for packusdw */
+                 intr_type = dst_type;
 #endif
-            }
+              }
+           }
+         } else if (util_cpu_caps.has_altivec) {
+            if (dst_type.sign) {
+              intrinsic = "llvm.ppc.altivec.vpkswus";
+           } else {
+              intrinsic = "llvm.ppc.altivec.vpkuwus";
+           }
          }
          break;
       case 16:
          if (dst_type.sign) {
-            intrinsic = "llvm.x86.sse2.packsswb.128";
-         }
-         else {
-            intrinsic = "llvm.x86.sse2.packuswb.128";
+            if (util_cpu_caps.has_sse2) {
+              intrinsic = "llvm.x86.sse2.packsswb.128";
+            } else if (util_cpu_caps.has_altivec) {
+              intrinsic = "llvm.ppc.altivec.vpkshss";
+            }
+         } else {
+            if (util_cpu_caps.has_sse2) {
+              intrinsic = "llvm.x86.sse2.packuswb.128";
+            } else if (util_cpu_caps.has_altivec) {
+	      intrinsic = "llvm.ppc.altivec.vpkshus";
+            }
          }
          break;
       /* default uses generic shuffle below */




More information about the mesa-commit mailing list