X86: Don't drop half of the mask when converting 2-address shufps into 3-address...
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 5 Oct 2014 16:14:29 +0000 (16:14 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 5 Oct 2014 16:14:29 +0000 (16:14 +0000)
It's debatable whether this transform is useful at all, but for now make sure
we don't generate invalid asm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219084 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.cpp
test/CodeGen/X86/3addr-shufps.ll [new file with mode: 0644]

index 08306419f5a6e38218d3a022ad908c5cf0ee26e0..dc97185ed9559f95558307d697bab797f6955aec 100644 (file)
@@ -2146,7 +2146,7 @@ X86InstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
     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;
diff --git a/test/CodeGen/X86/3addr-shufps.ll b/test/CodeGen/X86/3addr-shufps.ll
new file mode 100644 (file)
index 0000000..8603df9
--- /dev/null
@@ -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
+}