Index: llvm/lib/Target/X86/X86ISelLowering.h =================================================================== --- llvm/lib/Target/X86/X86ISelLowering.h +++ llvm/lib/Target/X86/X86ISelLowering.h @@ -590,6 +590,9 @@ // Load, scalar_to_vector, and zero extend. VZEXT_LOAD, + // extract_vector_elt, store. + VEXTRACT_STORE, + // Store FP control world into i16 memory. FNSTCW16m, Index: llvm/lib/Target/X86/X86ISelLowering.cpp =================================================================== --- llvm/lib/Target/X86/X86ISelLowering.cpp +++ llvm/lib/Target/X86/X86ISelLowering.cpp @@ -25578,8 +25578,19 @@ return false; } +// TODO: In 32-bit mode, use MOVLPS when SSE1 is available? +// TODO: In 32-bit mode, use FISTP when X87 is available? bool X86TargetLowering::shouldExpandAtomicStoreInIR(StoreInst *SI) const { - return needsCmpXchgNb(SI->getValueOperand()->getType()); + Type *MemType = SI->getValueOperand()->getType(); + + bool NoImplicitFloatOps = + SI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat); + if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() && + !Subtarget.useSoftFloat() && !NoImplicitFloatOps && Subtarget.hasSSE2() && + SI->getOrdering() != AtomicOrdering::SequentiallyConsistent) + return false; + + return needsCmpXchgNb(MemType); } // Note: this turns large loads into lock cmpxchg8b/16b. @@ -26214,28 +26225,47 @@ DAG.getUNDEF(VT), LockOp.getValue(1)); } -static SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) { - SDNode *Node = Op.getNode(); +static SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG, + const X86Subtarget &Subtarget) { + auto *Node = cast(Op.getNode()); SDLoc dl(Node); - EVT VT = cast(Node)->getMemoryVT(); + EVT VT = Node->getMemoryVT(); + + bool IsSeqCst = Node->getOrdering() == AtomicOrdering::SequentiallyConsistent; + + // If this store is not sequentially consistent and the type is legal + // we can just keep it. + if (!IsSeqCst && DAG.getTargetLoweringInfo().isTypeLegal(VT)) + return Op; + + if (!IsSeqCst && VT == MVT::i64) { + // For illegal i64 atomic_stores, we can try to use MOVQ if SSE2 is enabled. + // FIXME: Use movlps with SSE1. + // FIXME: Use fist with X87. + bool NoImplicitFloatOps = + DAG.getMachineFunction().getFunction().hasFnAttribute( + Attribute::NoImplicitFloat); + if (!Subtarget.useSoftFloat() && !NoImplicitFloatOps && + Subtarget.hasSSE2()) { + SDValue SclToVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v2i64, + Node->getOperand(2)); + SDVTList Tys = DAG.getVTList(MVT::Other); + SDValue Ops[] = { Node->getChain(), SclToVec, Node->getBasePtr() }; + SDValue St = DAG.getMemIntrinsicNode(X86ISD::VEXTRACT_STORE, dl, Tys, Ops, + MVT::i64, Node->getMemOperand()); + return St; + } + } // Convert seq_cst store -> xchg // Convert wide store -> swap (-> cmpxchg8b/cmpxchg16b) - // FIXME: On 32-bit, store -> fist or movq would be more efficient - // (The only way to get a 16-byte store is cmpxchg16b) // FIXME: 16-byte ATOMIC_SWAP isn't actually hooked up at the moment. - if (cast(Node)->getOrdering() == - AtomicOrdering::SequentiallyConsistent || - !DAG.getTargetLoweringInfo().isTypeLegal(VT)) { - SDValue Swap = DAG.getAtomic(ISD::ATOMIC_SWAP, dl, - cast(Node)->getMemoryVT(), - Node->getOperand(0), - Node->getOperand(1), Node->getOperand(2), - cast(Node)->getMemOperand()); - return Swap.getValue(1); - } - // Other atomic stores have a simple pattern. - return Op; + SDValue Swap = DAG.getAtomic(ISD::ATOMIC_SWAP, dl, + Node->getMemoryVT(), + Node->getOperand(0), + Node->getOperand(1), Node->getOperand(2), + Node->getMemOperand()); + return Swap.getValue(1); } static SDValue LowerADDSUBCARRY(SDValue Op, SelectionDAG &DAG) { @@ -26656,7 +26686,7 @@ case ISD::ATOMIC_LOAD_OR: case ISD::ATOMIC_LOAD_XOR: case ISD::ATOMIC_LOAD_AND: return lowerAtomicArith(Op, DAG, Subtarget); - case ISD::ATOMIC_STORE: return LowerATOMIC_STORE(Op, DAG); + case ISD::ATOMIC_STORE: return LowerATOMIC_STORE(Op, DAG, Subtarget); case ISD::BITREVERSE: return LowerBITREVERSE(Op, Subtarget, DAG); case ISD::BUILD_VECTOR: return LowerBUILD_VECTOR(Op, DAG); case ISD::CONCAT_VECTORS: return LowerCONCAT_VECTORS(Op, Subtarget, DAG); @@ -27729,6 +27759,7 @@ case X86ISD::LAND: return "X86ISD::LAND"; case X86ISD::VZEXT_MOVL: return "X86ISD::VZEXT_MOVL"; case X86ISD::VZEXT_LOAD: return "X86ISD::VZEXT_LOAD"; + case X86ISD::VEXTRACT_STORE: return "X86ISD::VEXTRACT_STORE"; case X86ISD::VTRUNC: return "X86ISD::VTRUNC"; case X86ISD::VTRUNCS: return "X86ISD::VTRUNCS"; case X86ISD::VTRUNCUS: return "X86ISD::VTRUNCUS"; Index: llvm/lib/Target/X86/X86InstrAVX512.td =================================================================== --- llvm/lib/Target/X86/X86InstrAVX512.td +++ llvm/lib/Target/X86/X86InstrAVX512.td @@ -3839,6 +3839,11 @@ def : InstAlias<"vmovq.s\t{$src, $dst|$dst, $src}", (VMOVPQI2QIZrr VR128X:$dst, VR128X:$src), 0>; +let Predicates = [HasAVX512] in { + def : Pat<(X86vextractstore (v2i64 VR128X:$src), addr:$dst), + (VMOVPQI2QIZmr addr:$dst, VR128X:$src)>; +} + // Move Scalar Single to Double Int // let ExeDomain = SSEPackedInt, isCodeGenOnly = 1 in { Index: llvm/lib/Target/X86/X86InstrFragmentsSIMD.td =================================================================== --- llvm/lib/Target/X86/X86InstrFragmentsSIMD.td +++ llvm/lib/Target/X86/X86InstrFragmentsSIMD.td @@ -101,6 +101,8 @@ def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad, [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; +def X86vextractstore : SDNode<"X86ISD::VEXTRACT_STORE", SDTStore, + [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; def SDTVtrunc : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>, SDTCisInt<0>, SDTCisInt<1>, Index: llvm/lib/Target/X86/X86InstrSSE.td =================================================================== --- llvm/lib/Target/X86/X86InstrSSE.td +++ llvm/lib/Target/X86/X86InstrSSE.td @@ -4406,12 +4406,18 @@ (SUBREG_TO_REG (i64 0), (v2i64 (VMOVQI2PQIrm addr:$src)), sub_xmm)>; def : Pat<(v4i64 (X86vzload addr:$src)), (SUBREG_TO_REG (i64 0), (v2i64 (VMOVQI2PQIrm addr:$src)), sub_xmm)>; + + def : Pat<(X86vextractstore (v2i64 VR128:$src), addr:$dst), + (VMOVPQI2QImr addr:$dst, VR128:$src)>; } let Predicates = [UseSSE2] in { def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))), (MOVQI2PQIrm addr:$src)>; def : Pat<(v2i64 (X86vzload addr:$src)), (MOVQI2PQIrm addr:$src)>; + + def : Pat<(X86vextractstore (v2i64 VR128:$src), addr:$dst), + (MOVPQI2QImr addr:$dst, VR128:$src)>; } //===---------------------------------------------------------------------===// Index: llvm/test/CodeGen/X86/atomic-fp.ll =================================================================== --- llvm/test/CodeGen/X86/atomic-fp.ll +++ llvm/test/CodeGen/X86/atomic-fp.ll @@ -144,27 +144,15 @@ ; X86-SSE2: # %bb.0: ; X86-SSE2-NEXT: pushl %ebp ; X86-SSE2-NEXT: movl %esp, %ebp -; X86-SSE2-NEXT: pushl %ebx -; X86-SSE2-NEXT: pushl %esi ; X86-SSE2-NEXT: andl $-8, %esp ; X86-SSE2-NEXT: subl $8, %esp -; X86-SSE2-NEXT: movl 8(%ebp), %esi +; X86-SSE2-NEXT: movl 8(%ebp), %eax ; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero ; X86-SSE2-NEXT: addsd 12(%ebp), %xmm0 ; X86-SSE2-NEXT: movsd %xmm0, (%esp) -; X86-SSE2-NEXT: movl (%esp), %ebx -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-SSE2-NEXT: movl (%esi), %eax -; X86-SSE2-NEXT: movl 4(%esi), %edx -; X86-SSE2-NEXT: .p2align 4, 0x90 -; X86-SSE2-NEXT: .LBB1_1: # %atomicrmw.start -; X86-SSE2-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-SSE2-NEXT: lock cmpxchg8b (%esi) -; X86-SSE2-NEXT: jne .LBB1_1 -; X86-SSE2-NEXT: # %bb.2: # %atomicrmw.end -; X86-SSE2-NEXT: leal -8(%ebp), %esp -; X86-SSE2-NEXT: popl %esi -; X86-SSE2-NEXT: popl %ebx +; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero +; X86-SSE2-NEXT: movlps %xmm0, (%eax) +; X86-SSE2-NEXT: movl %ebp, %esp ; X86-SSE2-NEXT: popl %ebp ; X86-SSE2-NEXT: retl ; @@ -172,27 +160,15 @@ ; X86-AVX: # %bb.0: ; X86-AVX-NEXT: pushl %ebp ; X86-AVX-NEXT: movl %esp, %ebp -; X86-AVX-NEXT: pushl %ebx -; X86-AVX-NEXT: pushl %esi ; X86-AVX-NEXT: andl $-8, %esp ; X86-AVX-NEXT: subl $8, %esp -; X86-AVX-NEXT: movl 8(%ebp), %esi +; X86-AVX-NEXT: movl 8(%ebp), %eax ; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero ; X86-AVX-NEXT: vaddsd 12(%ebp), %xmm0, %xmm0 ; X86-AVX-NEXT: vmovsd %xmm0, (%esp) -; X86-AVX-NEXT: movl (%esp), %ebx -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-AVX-NEXT: movl (%esi), %eax -; X86-AVX-NEXT: movl 4(%esi), %edx -; X86-AVX-NEXT: .p2align 4, 0x90 -; X86-AVX-NEXT: .LBB1_1: # %atomicrmw.start -; X86-AVX-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-AVX-NEXT: lock cmpxchg8b (%esi) -; X86-AVX-NEXT: jne .LBB1_1 -; X86-AVX-NEXT: # %bb.2: # %atomicrmw.end -; X86-AVX-NEXT: leal -8(%ebp), %esp -; X86-AVX-NEXT: popl %esi -; X86-AVX-NEXT: popl %ebx +; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero +; X86-AVX-NEXT: vmovlps %xmm0, (%eax) +; X86-AVX-NEXT: movl %ebp, %esp ; X86-AVX-NEXT: popl %ebp ; X86-AVX-NEXT: retl ; @@ -345,24 +321,14 @@ ; X86-SSE2: # %bb.0: ; X86-SSE2-NEXT: pushl %ebp ; X86-SSE2-NEXT: movl %esp, %ebp -; X86-SSE2-NEXT: pushl %ebx ; X86-SSE2-NEXT: andl $-8, %esp -; X86-SSE2-NEXT: subl $16, %esp +; X86-SSE2-NEXT: subl $8, %esp ; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero ; X86-SSE2-NEXT: addsd {{\.LCPI.*}}, %xmm0 ; X86-SSE2-NEXT: movsd %xmm0, (%esp) -; X86-SSE2-NEXT: movl (%esp), %ebx -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-SSE2-NEXT: movl glob64+4, %edx -; X86-SSE2-NEXT: movl glob64, %eax -; X86-SSE2-NEXT: .p2align 4, 0x90 -; X86-SSE2-NEXT: .LBB3_1: # %atomicrmw.start -; X86-SSE2-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-SSE2-NEXT: lock cmpxchg8b glob64 -; X86-SSE2-NEXT: jne .LBB3_1 -; X86-SSE2-NEXT: # %bb.2: # %atomicrmw.end -; X86-SSE2-NEXT: leal -4(%ebp), %esp -; X86-SSE2-NEXT: popl %ebx +; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero +; X86-SSE2-NEXT: movlps %xmm0, glob64 +; X86-SSE2-NEXT: movl %ebp, %esp ; X86-SSE2-NEXT: popl %ebp ; X86-SSE2-NEXT: retl ; @@ -370,24 +336,14 @@ ; X86-AVX: # %bb.0: ; X86-AVX-NEXT: pushl %ebp ; X86-AVX-NEXT: movl %esp, %ebp -; X86-AVX-NEXT: pushl %ebx ; X86-AVX-NEXT: andl $-8, %esp -; X86-AVX-NEXT: subl $16, %esp +; X86-AVX-NEXT: subl $8, %esp ; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero ; X86-AVX-NEXT: vaddsd {{\.LCPI.*}}, %xmm0, %xmm0 ; X86-AVX-NEXT: vmovsd %xmm0, (%esp) -; X86-AVX-NEXT: movl (%esp), %ebx -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-AVX-NEXT: movl glob64+4, %edx -; X86-AVX-NEXT: movl glob64, %eax -; X86-AVX-NEXT: .p2align 4, 0x90 -; X86-AVX-NEXT: .LBB3_1: # %atomicrmw.start -; X86-AVX-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-AVX-NEXT: lock cmpxchg8b glob64 -; X86-AVX-NEXT: jne .LBB3_1 -; X86-AVX-NEXT: # %bb.2: # %atomicrmw.end -; X86-AVX-NEXT: leal -4(%ebp), %esp -; X86-AVX-NEXT: popl %ebx +; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero +; X86-AVX-NEXT: vmovlps %xmm0, glob64 +; X86-AVX-NEXT: movl %ebp, %esp ; X86-AVX-NEXT: popl %ebp ; X86-AVX-NEXT: retl ; @@ -546,24 +502,14 @@ ; X86-SSE2: # %bb.0: ; X86-SSE2-NEXT: pushl %ebp ; X86-SSE2-NEXT: movl %esp, %ebp -; X86-SSE2-NEXT: pushl %ebx ; X86-SSE2-NEXT: andl $-8, %esp -; X86-SSE2-NEXT: subl $16, %esp +; X86-SSE2-NEXT: subl $8, %esp ; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero ; X86-SSE2-NEXT: addsd {{\.LCPI.*}}, %xmm0 ; X86-SSE2-NEXT: movsd %xmm0, (%esp) -; X86-SSE2-NEXT: movl (%esp), %ebx -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-SSE2-NEXT: movl -559038737, %eax -; X86-SSE2-NEXT: movl -559038733, %edx -; X86-SSE2-NEXT: .p2align 4, 0x90 -; X86-SSE2-NEXT: .LBB5_1: # %atomicrmw.start -; X86-SSE2-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-SSE2-NEXT: lock cmpxchg8b -559038737 -; X86-SSE2-NEXT: jne .LBB5_1 -; X86-SSE2-NEXT: # %bb.2: # %atomicrmw.end -; X86-SSE2-NEXT: leal -4(%ebp), %esp -; X86-SSE2-NEXT: popl %ebx +; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero +; X86-SSE2-NEXT: movlps %xmm0, -559038737 +; X86-SSE2-NEXT: movl %ebp, %esp ; X86-SSE2-NEXT: popl %ebp ; X86-SSE2-NEXT: retl ; @@ -571,24 +517,14 @@ ; X86-AVX: # %bb.0: ; X86-AVX-NEXT: pushl %ebp ; X86-AVX-NEXT: movl %esp, %ebp -; X86-AVX-NEXT: pushl %ebx ; X86-AVX-NEXT: andl $-8, %esp -; X86-AVX-NEXT: subl $16, %esp +; X86-AVX-NEXT: subl $8, %esp ; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero ; X86-AVX-NEXT: vaddsd {{\.LCPI.*}}, %xmm0, %xmm0 ; X86-AVX-NEXT: vmovsd %xmm0, (%esp) -; X86-AVX-NEXT: movl (%esp), %ebx -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-AVX-NEXT: movl -559038737, %eax -; X86-AVX-NEXT: movl -559038733, %edx -; X86-AVX-NEXT: .p2align 4, 0x90 -; X86-AVX-NEXT: .LBB5_1: # %atomicrmw.start -; X86-AVX-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-AVX-NEXT: lock cmpxchg8b -559038737 -; X86-AVX-NEXT: jne .LBB5_1 -; X86-AVX-NEXT: # %bb.2: # %atomicrmw.end -; X86-AVX-NEXT: leal -4(%ebp), %esp -; X86-AVX-NEXT: popl %ebx +; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero +; X86-AVX-NEXT: vmovlps %xmm0, -559038737 +; X86-AVX-NEXT: movl %ebp, %esp ; X86-AVX-NEXT: popl %ebp ; X86-AVX-NEXT: retl ; @@ -753,24 +689,14 @@ ; X86-SSE2: # %bb.0: ; X86-SSE2-NEXT: pushl %ebp ; X86-SSE2-NEXT: movl %esp, %ebp -; X86-SSE2-NEXT: pushl %ebx ; X86-SSE2-NEXT: andl $-8, %esp -; X86-SSE2-NEXT: subl $24, %esp +; X86-SSE2-NEXT: subl $16, %esp ; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero ; X86-SSE2-NEXT: addsd {{\.LCPI.*}}, %xmm0 -; X86-SSE2-NEXT: movsd %xmm0, {{[0-9]+}}(%esp) -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ebx -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-SSE2-NEXT: movl (%esp), %eax -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %edx -; X86-SSE2-NEXT: .p2align 4, 0x90 -; X86-SSE2-NEXT: .LBB7_1: # %atomicrmw.start -; X86-SSE2-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-SSE2-NEXT: lock cmpxchg8b (%esp) -; X86-SSE2-NEXT: jne .LBB7_1 -; X86-SSE2-NEXT: # %bb.2: # %atomicrmw.end -; X86-SSE2-NEXT: leal -4(%ebp), %esp -; X86-SSE2-NEXT: popl %ebx +; X86-SSE2-NEXT: movsd %xmm0, (%esp) +; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero +; X86-SSE2-NEXT: movlps %xmm0, {{[0-9]+}}(%esp) +; X86-SSE2-NEXT: movl %ebp, %esp ; X86-SSE2-NEXT: popl %ebp ; X86-SSE2-NEXT: retl ; @@ -778,24 +704,14 @@ ; X86-AVX: # %bb.0: ; X86-AVX-NEXT: pushl %ebp ; X86-AVX-NEXT: movl %esp, %ebp -; X86-AVX-NEXT: pushl %ebx ; X86-AVX-NEXT: andl $-8, %esp -; X86-AVX-NEXT: subl $24, %esp +; X86-AVX-NEXT: subl $16, %esp ; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero ; X86-AVX-NEXT: vaddsd {{\.LCPI.*}}, %xmm0, %xmm0 -; X86-AVX-NEXT: vmovsd %xmm0, {{[0-9]+}}(%esp) -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %ebx -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-AVX-NEXT: movl (%esp), %eax -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %edx -; X86-AVX-NEXT: .p2align 4, 0x90 -; X86-AVX-NEXT: .LBB7_1: # %atomicrmw.start -; X86-AVX-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-AVX-NEXT: lock cmpxchg8b (%esp) -; X86-AVX-NEXT: jne .LBB7_1 -; X86-AVX-NEXT: # %bb.2: # %atomicrmw.end -; X86-AVX-NEXT: leal -4(%ebp), %esp -; X86-AVX-NEXT: popl %ebx +; X86-AVX-NEXT: vmovsd %xmm0, (%esp) +; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero +; X86-AVX-NEXT: vmovlps %xmm0, {{[0-9]+}}(%esp) +; X86-AVX-NEXT: movl %ebp, %esp ; X86-AVX-NEXT: popl %ebp ; X86-AVX-NEXT: retl ; @@ -903,30 +819,16 @@ ; X86-SSE2: # %bb.0: # %bb ; X86-SSE2-NEXT: pushl %ebp ; X86-SSE2-NEXT: movl %esp, %ebp -; X86-SSE2-NEXT: pushl %ebx -; X86-SSE2-NEXT: pushl %edi -; X86-SSE2-NEXT: pushl %esi ; X86-SSE2-NEXT: andl $-8, %esp -; X86-SSE2-NEXT: subl $16, %esp -; X86-SSE2-NEXT: movl 20(%ebp), %esi -; X86-SSE2-NEXT: movl 8(%ebp), %edi +; X86-SSE2-NEXT: subl $8, %esp +; X86-SSE2-NEXT: movl 20(%ebp), %eax +; X86-SSE2-NEXT: movl 8(%ebp), %ecx ; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero ; X86-SSE2-NEXT: addsd 12(%ebp), %xmm0 ; X86-SSE2-NEXT: movsd %xmm0, (%esp) -; X86-SSE2-NEXT: movl (%esp), %ebx -; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-SSE2-NEXT: movl (%edi,%esi,8), %eax -; X86-SSE2-NEXT: movl 4(%edi,%esi,8), %edx -; X86-SSE2-NEXT: .p2align 4, 0x90 -; X86-SSE2-NEXT: .LBB8_1: # %atomicrmw.start -; X86-SSE2-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-SSE2-NEXT: lock cmpxchg8b (%edi,%esi,8) -; X86-SSE2-NEXT: jne .LBB8_1 -; X86-SSE2-NEXT: # %bb.2: # %atomicrmw.end -; X86-SSE2-NEXT: leal -12(%ebp), %esp -; X86-SSE2-NEXT: popl %esi -; X86-SSE2-NEXT: popl %edi -; X86-SSE2-NEXT: popl %ebx +; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero +; X86-SSE2-NEXT: movlps %xmm0, (%ecx,%eax,8) +; X86-SSE2-NEXT: movl %ebp, %esp ; X86-SSE2-NEXT: popl %ebp ; X86-SSE2-NEXT: retl ; @@ -934,30 +836,16 @@ ; X86-AVX: # %bb.0: # %bb ; X86-AVX-NEXT: pushl %ebp ; X86-AVX-NEXT: movl %esp, %ebp -; X86-AVX-NEXT: pushl %ebx -; X86-AVX-NEXT: pushl %edi -; X86-AVX-NEXT: pushl %esi ; X86-AVX-NEXT: andl $-8, %esp -; X86-AVX-NEXT: subl $16, %esp -; X86-AVX-NEXT: movl 20(%ebp), %esi -; X86-AVX-NEXT: movl 8(%ebp), %edi +; X86-AVX-NEXT: subl $8, %esp +; X86-AVX-NEXT: movl 20(%ebp), %eax +; X86-AVX-NEXT: movl 8(%ebp), %ecx ; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero ; X86-AVX-NEXT: vaddsd 12(%ebp), %xmm0, %xmm0 ; X86-AVX-NEXT: vmovsd %xmm0, (%esp) -; X86-AVX-NEXT: movl (%esp), %ebx -; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X86-AVX-NEXT: movl (%edi,%esi,8), %eax -; X86-AVX-NEXT: movl 4(%edi,%esi,8), %edx -; X86-AVX-NEXT: .p2align 4, 0x90 -; X86-AVX-NEXT: .LBB8_1: # %atomicrmw.start -; X86-AVX-NEXT: # =>This Inner Loop Header: Depth=1 -; X86-AVX-NEXT: lock cmpxchg8b (%edi,%esi,8) -; X86-AVX-NEXT: jne .LBB8_1 -; X86-AVX-NEXT: # %bb.2: # %atomicrmw.end -; X86-AVX-NEXT: leal -12(%ebp), %esp -; X86-AVX-NEXT: popl %esi -; X86-AVX-NEXT: popl %edi -; X86-AVX-NEXT: popl %ebx +; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero +; X86-AVX-NEXT: vmovlps %xmm0, (%ecx,%eax,8) +; X86-AVX-NEXT: movl %ebp, %esp ; X86-AVX-NEXT: popl %ebp ; X86-AVX-NEXT: retl ; Index: llvm/test/CodeGen/X86/atomic6432.ll =================================================================== --- llvm/test/CodeGen/X86/atomic6432.ll +++ llvm/test/CodeGen/X86/atomic6432.ll @@ -835,34 +835,11 @@ define void @atomic_fetch_store64(i64 %x) nounwind { ; X32-LABEL: atomic_fetch_store64: ; X32: # %bb.0: -; X32-NEXT: pushl %ebx -; X32-NEXT: subl $20, %esp +; X32-NEXT: movl {{[0-9]+}}(%esp), %eax ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X32-NEXT: movl {{[0-9]+}}(%esp), %ebx -; X32-NEXT: movl sc64+4, %eax -; X32-NEXT: movl sc64, %edx -; X32-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill -; X32-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill -; X32-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill -; X32-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill -; X32-NEXT: jmp .LBB11_1 -; X32-NEXT: .LBB11_1: # %atomicrmw.start -; X32-NEXT: # =>This Inner Loop Header: Depth=1 -; X32-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload -; X32-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload -; X32-NEXT: movl %eax, (%esp) # 4-byte Spill -; X32-NEXT: movl %ecx, %eax -; X32-NEXT: movl (%esp), %edx # 4-byte Reload -; X32-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload -; X32-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload -; X32-NEXT: lock cmpxchg8b sc64 -; X32-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill -; X32-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill -; X32-NEXT: jne .LBB11_1 -; X32-NEXT: jmp .LBB11_2 -; X32-NEXT: .LBB11_2: # %atomicrmw.end -; X32-NEXT: addl $20, %esp -; X32-NEXT: popl %ebx +; X32-NEXT: movd %ecx, %xmm0 +; X32-NEXT: pinsrd $1, %eax, %xmm0 +; X32-NEXT: movq %xmm0, sc64 ; X32-NEXT: retl store atomic i64 %x, i64* @sc64 release, align 8 ret void