[llvm-commits] [llvm] r66645 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/vec_shuffle-36.ll

Mon P Wang wangmp at apple.com
Tue Mar 10 23:35:12 PDT 2009


Author: wangmp
Date: Wed Mar 11 01:35:11 2009
New Revision: 66645

URL: http://llvm.org/viewvc/llvm-project?rev=66645&view=rev
Log:
Fixed a v8i16 shuffle case that should generate a pshufb instead of a pshuflw/hw.

Added:
    llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll
Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=66645&r1=66644&r2=66645&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Mar 11 01:35:11 2009
@@ -3630,8 +3630,11 @@
     // Rewrite the MaskVals and assign NewV to V1 if NewV now contains all the
     // source words for the shuffle, to aid later transformations.
     bool AllWordsInNewV = true;
+    bool InOrder[2] = { true, true };
     for (unsigned i = 0; i != 8; ++i) {
       int idx = MaskVals[i];
+      if (idx != (int)i)
+        InOrder[i/4] = false;
       if (idx < 0 || (idx/4) == BestLoQuad || (idx/4) == BestHiQuad)
         continue;
       AllWordsInNewV = false;
@@ -3658,7 +3661,7 @@
 
     // If we've eliminated the use of V2, and the new mask is a pshuflw or
     // pshufhw, that's as cheap as it gets.  Return the new shuffle.
-    if (pshufhw || pshuflw) {
+    if ((pshufhw && InOrder[0]) || (pshuflw && InOrder[1])) {
       MaskV.clear();
       for (unsigned i = 0; i != 8; ++i)
         MaskV.push_back((MaskVals[i] < 0) ? DAG.getUNDEF(MVT::i16)

Added: llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll?rev=66645&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll (added)
+++ llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll Wed Mar 11 01:35:11 2009
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | llc -march=x86 -mattr=sse41 -o %t -f
+; RUN: grep pshufb %t | count 1
+
+
+define <8 x i16> @shuf6(<8 x i16> %T0, <8 x i16> %T1) nounwind readnone {
+entry:
+	%tmp9 = shufflevector <8 x i16> %T0, <8 x i16> %T1, <8 x i32> < i32 3, i32 2, i32 0, i32 2, i32 1, i32 5, i32 6 , i32 undef >
+	ret <8 x i16> %tmp9
+}





More information about the llvm-commits mailing list