Skip to content

Commit

Permalink
[X86] Prefer locked stack op over mfence for seq_cst 64-bit stores on…
Browse files Browse the repository at this point in the history
… 32-bit targets

This is a follow on to D58632, with the same logic. Given a memory operation which needs ordering, but doesn't need to modify any particular address, prefer to use a locked stack op over an mfence.

Differential Revision: https://reviews.llvm.org/D61863

llvm-svn: 360649
  • Loading branch information
preames authored and MrSidims committed May 24, 2019
1 parent 430c1cc commit 0e6e9fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Expand Up @@ -26456,9 +26456,10 @@ static SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG,
Ops, MVT::i64,
Node->getMemOperand());

// If this is a sequentially consistent store, also emit an mfence.
// If this is a sequentially consistent store, also emit an appropriate
// barrier.
if (IsSeqCst)
Chain = DAG.getNode(X86ISD::MFENCE, dl, MVT::Other, Chain);
Chain = emitLockedStackOp(DAG, Subtarget, Chain, dl);

return Chain;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/atomic-load-store-wide.ll
Expand Up @@ -11,7 +11,7 @@ define void @test1(i64* %ptr, i64 %val1) {
; SSE42-NEXT: movl {{[0-9]+}}(%esp), %eax
; SSE42-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
; SSE42-NEXT: movlps %xmm0, (%eax)
; SSE42-NEXT: mfence
; SSE42-NEXT: lock orl $0, (%esp)
; SSE42-NEXT: retl
;
; NOSSE-LABEL: test1:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/X86/atomic-non-integer.ll
Expand Up @@ -710,15 +710,15 @@ define void @store_double_seq_cst(double* %fptr, double %v) {
; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
; X86-SSE2-NEXT: movlps %xmm0, (%eax)
; X86-SSE2-NEXT: mfence
; X86-SSE2-NEXT: lock orl $0, (%esp)
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: store_double_seq_cst:
; X86-AVX: # %bb.0:
; X86-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
; X86-AVX-NEXT: vmovlps %xmm0, (%eax)
; X86-AVX-NEXT: mfence
; X86-AVX-NEXT: lock orl $0, (%esp)
; X86-AVX-NEXT: retl
;
; X86-NOSSE-LABEL: store_double_seq_cst:
Expand Down

0 comments on commit 0e6e9fc

Please sign in to comment.