When expanding atomic load arith instructions, do not lose target flags. rdar://12453106

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165568 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2012-10-09 23:48:33 +00:00
parent c0dfffa448
commit e61e516a51
2 changed files with 63 additions and 44 deletions

View File

@ -12389,9 +12389,12 @@ X86TargetLowering::EmitAtomicLoadArith6432(MachineInstr *MI,
// Hi
MIB = BuildMI(thisMBB, DL, TII->get(LOADOpc), X86::EDX);
for (unsigned i = 0; i < X86::AddrNumOperands; ++i) {
if (i == X86::AddrDisp)
if (i == X86::AddrDisp) {
MIB.addDisp(MI->getOperand(MemOpndSlot + i), 4); // 4 == sizeof(i32)
else
// Don't forget to transfer the target flag.
MachineOperand &MO = MIB->getOperand(MIB->getNumOperands()-1);
MO.setTargetFlags(MI->getOperand(MemOpndSlot + i).getTargetFlags());
} else
MIB.addOperand(MI->getOperand(MemOpndSlot + i));
}
MIB.setMemRefs(MMOBegin, MMOEnd);

View File

@ -1,51 +1,67 @@
; RUN: llc -march=x86 -mattr=+cmov -mtriple=i386-pc-linux < %s | FileCheck %s
; RUN: llc -march=x86 -mattr=+cmov -mtriple=i386-pc-linux < %s | FileCheck %s -check-prefix=LINUX
; RUN: llc -march=x86 -mtriple=i386-macosx -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC
@sc64 = external global i64
define void @atomic_maxmin_i6432() {
; CHECK: atomic_maxmin_i6432
; LINUX: atomic_maxmin_i6432
%1 = atomicrmw max i64* @sc64, i64 5 acquire
; CHECK: [[LABEL:.LBB[0-9]+_[0-9]+]]
; CHECK: cmpl
; CHECK: setl
; CHECK: cmpl
; CHECK: setl
; CHECK: cmovne
; CHECK: cmovne
; CHECK: lock
; CHECK-NEXT: cmpxchg8b
; CHECK: jne [[LABEL]]
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
; LINUX: cmpl
; LINUX: setl
; LINUX: cmpl
; LINUX: setl
; LINUX: cmovne
; LINUX: cmovne
; LINUX: lock
; LINUX-NEXT: cmpxchg8b
; LINUX: jne [[LABEL]]
%2 = atomicrmw min i64* @sc64, i64 6 acquire
; CHECK: [[LABEL:.LBB[0-9]+_[0-9]+]]
; CHECK: cmpl
; CHECK: setg
; CHECK: cmpl
; CHECK: setg
; CHECK: cmovne
; CHECK: cmovne
; CHECK: lock
; CHECK-NEXT: cmpxchg8b
; CHECK: jne [[LABEL]]
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
; LINUX: cmpl
; LINUX: setg
; LINUX: cmpl
; LINUX: setg
; LINUX: cmovne
; LINUX: cmovne
; LINUX: lock
; LINUX-NEXT: cmpxchg8b
; LINUX: jne [[LABEL]]
%3 = atomicrmw umax i64* @sc64, i64 7 acquire
; CHECK: [[LABEL:.LBB[0-9]+_[0-9]+]]
; CHECK: cmpl
; CHECK: setb
; CHECK: cmpl
; CHECK: setb
; CHECK: cmovne
; CHECK: cmovne
; CHECK: lock
; CHECK-NEXT: cmpxchg8b
; CHECK: jne [[LABEL]]
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
; LINUX: cmpl
; LINUX: setb
; LINUX: cmpl
; LINUX: setb
; LINUX: cmovne
; LINUX: cmovne
; LINUX: lock
; LINUX-NEXT: cmpxchg8b
; LINUX: jne [[LABEL]]
%4 = atomicrmw umin i64* @sc64, i64 8 acquire
; CHECK: [[LABEL:.LBB[0-9]+_[0-9]+]]
; CHECK: cmpl
; CHECK: seta
; CHECK: cmpl
; CHECK: seta
; CHECK: cmovne
; CHECK: cmovne
; CHECK: lock
; CHECK-NEXT: cmpxchg8b
; CHECK: jne [[LABEL]]
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
; LINUX: cmpl
; LINUX: seta
; LINUX: cmpl
; LINUX: seta
; LINUX: cmovne
; LINUX: cmovne
; LINUX: lock
; LINUX-NEXT: cmpxchg8b
; LINUX: jne [[LABEL]]
ret void
}
; rdar://12453106
@id = internal global i64 0, align 8
define void @tf_bug(i8* %ptr) nounwind {
; PIC: tf_bug:
; PIC: movl _id-L1$pb(
; PIC: movl (_id-L1$pb)+4(
%tmp1 = atomicrmw add i64* @id, i64 1 seq_cst
%tmp2 = add i64 %tmp1, 1
%tmp3 = bitcast i8* %ptr to i64*
store i64 %tmp2, i64* %tmp3, align 4
ret void
}