1; RUN: llc -march=x86 -mattr=+cmov,cx16 -mtriple=i386-pc-linux -verify-machineinstrs < %s | FileCheck %s -check-prefix=LINUX
2; RUN: llc -march=x86 -mattr=cx16 -mtriple=i386-macosx -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s -check-prefix=PIC
3
4@sc64 = external global i64
5
6define void @atomic_maxmin_i6432() {
7; LINUX: atomic_maxmin_i6432
8  %1 = atomicrmw max  i64* @sc64, i64 5 acquire
9; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
10; LINUX: cmpl
11; LINUX: seta
12; LINUX: cmovne
13; LINUX: cmovne
14; LINUX: lock
15; LINUX-NEXT: cmpxchg8b
16; LINUX: jne [[LABEL]]
17  %2 = atomicrmw min  i64* @sc64, i64 6 acquire
18; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
19; LINUX: cmpl
20; LINUX: setb
21; LINUX: cmovne
22; LINUX: cmovne
23; LINUX: lock
24; LINUX-NEXT: cmpxchg8b
25; LINUX: jne [[LABEL]]
26  %3 = atomicrmw umax i64* @sc64, i64 7 acquire
27; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
28; LINUX: cmpl
29; LINUX: seta
30; LINUX: cmovne
31; LINUX: cmovne
32; LINUX: lock
33; LINUX-NEXT: cmpxchg8b
34; LINUX: jne [[LABEL]]
35  %4 = atomicrmw umin i64* @sc64, i64 8 acquire
36; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
37; LINUX: cmpl
38; LINUX: setb
39; LINUX: cmovne
40; LINUX: cmovne
41; LINUX: lock
42; LINUX-NEXT: cmpxchg8b
43; LINUX: jne [[LABEL]]
44  ret void
45}
46
47; rdar://12453106
48@id = internal global i64 0, align 8
49
50define void @tf_bug(i8* %ptr) nounwind {
51; PIC-LABEL: tf_bug:
52; PIC-DAG: movl _id-L1$pb(
53; PIC-DAG: movl (_id-L1$pb)+4(
54  %tmp1 = atomicrmw add i64* @id, i64 1 seq_cst
55  %tmp2 = add i64 %tmp1, 1
56  %tmp3 = bitcast i8* %ptr to i64*
57  store i64 %tmp2, i64* %tmp3, align 4
58  ret void
59}
60