summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2016-04-27 01:35:29 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2016-04-27 01:35:29 +0000
commit19a2ee591a1249d1d4b9657bf5f2089ec2ad2fa1 (patch)
tree9786ad88a079b154e10277e04b739b597b54a56a
parente68363a03ca541a55d67be1da05fea8a5a3c54af (diff)
downloadbcm5719-llvm-19a2ee591a1249d1d4b9657bf5f2089ec2ad2fa1.tar.gz
bcm5719-llvm-19a2ee591a1249d1d4b9657bf5f2089ec2ad2fa1.zip
[X86] Don't assume that MMX extractelts are from index 0.
It's probably the case for all 3 MMX users out there, but with hand-crafted IR, you can trigger selection failures. Fix that. llvm-svn: 267652
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp4
-rw-r--r--llvm/test/CodeGen/X86/vec_extract-mmx.ll28
2 files changed, 31 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index d966d7249a3..a6973995f46 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -25221,7 +25221,9 @@ static SDValue combineExtractVectorElt(SDNode *N, SelectionDAG &DAG,
// Detect mmx to i32 conversion through a v2i32 elt extract.
if (InputVector.getOpcode() == ISD::BITCAST && InputVector.hasOneUse() &&
N->getValueType(0) == MVT::i32 &&
- InputVector.getValueType() == MVT::v2i32) {
+ InputVector.getValueType() == MVT::v2i32 &&
+ isa<ConstantSDNode>(N->getOperand(1)) &&
+ N->getConstantOperandVal(1) == 0) {
SDValue MMXSrc = InputVector.getNode()->getOperand(0);
// The bitcast source is a direct mmx result.
diff --git a/llvm/test/CodeGen/X86/vec_extract-mmx.ll b/llvm/test/CodeGen/X86/vec_extract-mmx.ll
index 4d1ecd14af8..329437cfeda 100644
--- a/llvm/test/CodeGen/X86/vec_extract-mmx.ll
+++ b/llvm/test/CodeGen/X86/vec_extract-mmx.ll
@@ -140,5 +140,33 @@ define i32 @test3(x86_mmx %a) nounwind {
ret i32 %tmp1
}
+; Verify we don't muck with extractelts from the upper lane.
+define i32 @test4(x86_mmx %a) nounwind {
+; X32-LABEL: test4:
+; X32: # BB#0:
+; X32-NEXT: pushl %ebp
+; X32-NEXT: movl %esp, %ebp
+; X32-NEXT: andl $-8, %esp
+; X32-NEXT: subl $8, %esp
+; X32-NEXT: movq %mm0, (%esp)
+; X32-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; X32-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,3,0,1]
+; X32-NEXT: movd %xmm0, %eax
+; X32-NEXT: movl %ebp, %esp
+; X32-NEXT: popl %ebp
+; X32-NEXT: retl
+;
+; X64-LABEL: test4:
+; X64: # BB#0:
+; X64-NEXT: movq %mm0, -{{[0-9]+}}(%rsp)
+; X64-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
+; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,3,0,1]
+; X64-NEXT: movd %xmm0, %eax
+; X64-NEXT: retq
+ %tmp0 = bitcast x86_mmx %a to <2 x i32>
+ %tmp1 = extractelement <2 x i32> %tmp0, i32 1
+ ret i32 %tmp1
+}
+
declare x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx, i8)
declare void @llvm.x86.mmx.emms()
OpenPOWER on IntegriCloud