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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2014-10-05 16:14:29 +00:00
parent a0cb2c75b0
commit 88b3a52eec
2 changed files with 12 additions and 1 deletions

View 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;

View File

@ -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
}