[llvm-commits] [llvm] r165568 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/atomic-minmax-i6432.ll
Evan Cheng
evan.cheng at apple.com
Tue Oct 9 16:48:33 PDT 2012
Author: evancheng
Date: Tue Oct 9 18:48:33 2012
New Revision: 165568
URL: http://llvm.org/viewvc/llvm-project?rev=165568&view=rev
Log:
When expanding atomic load arith instructions, do not lose target flags. rdar://12453106
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/atomic-minmax-i6432.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=165568&r1=165567&r2=165568&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Oct 9 18:48:33 2012
@@ -12389,9 +12389,12 @@
// 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);
Modified: llvm/trunk/test/CodeGen/X86/atomic-minmax-i6432.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/atomic-minmax-i6432.ll?rev=165568&r1=165567&r2=165568&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/atomic-minmax-i6432.ll (original)
+++ llvm/trunk/test/CodeGen/X86/atomic-minmax-i6432.ll Tue Oct 9 18:48:33 2012
@@ -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
+ at 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
}
More information about the llvm-commits
mailing list