[llvm] r219084 - X86: Don't drop half of the mask when converting 2-address shufps into 3-address pshufd.

Benjamin Kramer benny.kra at googlemail.com
Sun Oct 5 09:14:29 PDT 2014


Author: d0k
Date: Sun Oct  5 11:14:29 2014
New Revision: 219084

URL: http://llvm.org/viewvc/llvm-project?rev=219084&view=rev
Log:
X86: Don't drop half of the mask when converting 2-address shufps into 3-address pshufd.

It's debatable whether this transform is useful at all, but for now make sure
we don't generate invalid asm.

Added:
    llvm/trunk/test/CodeGen/X86/3addr-shufps.ll
Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=219084&r1=219083&r2=219084&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Sun Oct  5 11:14:29 2014
@@ -2146,7 +2146,7 @@ X86InstrInfo::convertToThreeAddress(Mach
     unsigned B = MI->getOperand(1).getReg();
     unsigned C = MI->getOperand(2).getReg();
     if (B != C) return nullptr;
-    unsigned M = MI->getOperand(3).getImm();
+    int64_t M = MI->getOperand(3).getImm();
     NewMI = BuildMI(MF, MI->getDebugLoc(), get(X86::PSHUFDri))
       .addOperand(Dest).addOperand(Src).addImm(M);
     break;

Added: llvm/trunk/test/CodeGen/X86/3addr-shufps.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/3addr-shufps.ll?rev=219084&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/3addr-shufps.ll (added)
+++ llvm/trunk/test/CodeGen/X86/3addr-shufps.ll Sun Oct  5 11:14:29 2014
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=x86_64-apple-darwin13 -mcpu=pentium4 | FileCheck %s
+
+define <4 x float> @test1(<4 x i32>, <4 x float> %b) {
+  %s = shufflevector <4 x float> %b, <4 x float> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
+  ret <4 x float> %s
+
+; We convert shufps -> pshufd here to save a move.
+; CHECK-LABEL: test1:
+; CHECK:         pshufd $-27, %xmm1, %xmm0
+; CHECK-NEXT:    ret
+}





More information about the llvm-commits mailing list