xref: /llvm-project/llvm/test/tools/llvm-reduce/reduce-atomic-ordering.ll (revision 83da1a6a3fe81c382ea03177a4422d0ec8cfcff6)
1; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=atomic-ordering --test FileCheck --test-arg --check-prefixes=INTERESTING,CHECK --test-arg %s --test-arg --input-file %s -o %t
2; RUN: FileCheck -check-prefixes=RESULT,CHECK %s < %t
3
4; CHECK-LABEL: @load_atomic_keep(
5; INTERESTING: seq_cst
6; RESULT: %op = load atomic i32, ptr %ptr syncscope("agent") seq_cst, align 4
7define i32 @load_atomic_keep(ptr %ptr) {
8  %op = load atomic i32, ptr %ptr syncscope("agent") seq_cst, align 4
9  ret i32 %op
10}
11
12; CHECK-LABEL: @load_atomic_drop(
13; INTERESTING: load
14; RESULT: %op = load i32, ptr %ptr, align 4
15define i32 @load_atomic_drop(ptr %ptr) {
16  %op = load atomic i32, ptr %ptr syncscope("agent") seq_cst, align 4
17  ret i32 %op
18}
19
20; CHECK-LABEL: @store_atomic_keep(
21; INTERESTING: syncscope("agent")
22; RESULT: store atomic i32 0, ptr %ptr syncscope("agent") seq_cst, align 4
23define void @store_atomic_keep(ptr %ptr) {
24  store atomic i32 0, ptr %ptr syncscope("agent") seq_cst, align 4
25  ret void
26}
27
28; CHECK-LABEL: @store_atomic_drop(
29; INTERESTING: store
30; RESULT: store i32 0, ptr %ptr, align 4
31define void @store_atomic_drop(ptr %ptr) {
32  store atomic i32 0, ptr %ptr syncscope("agent") seq_cst, align 4
33  ret void
34}
35
36; CHECK-LABEL: @atomicrmw_atomic_seq_cst_keep(
37; INTERESTING: seq_cst
38; RESULT: %val = atomicrmw add ptr %ptr, i32 3 syncscope("agent") seq_cst, align 4
39define i32 @atomicrmw_atomic_seq_cst_keep(ptr %ptr) {
40  %val = atomicrmw add ptr %ptr, i32 3 syncscope("agent") seq_cst, align 4
41  ret i32 %val
42}
43
44; CHECK-LABEL: @atomicrmw_atomic_seq_cst_drop(
45; INTERESTING: atomicrmw
46; RESULT: %val = atomicrmw add ptr %ptr, i32 3 monotonic, align 4
47define i32 @atomicrmw_atomic_seq_cst_drop(ptr %ptr) {
48  %val = atomicrmw add ptr %ptr, i32 3 seq_cst
49  ret i32 %val
50}
51
52; CHECK-LABEL: @cmpxchg_atomic_seq_cst_seq_cst_keep(
53; INTERESTING: seq_cst seq_cst
54; RESULT: %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst, align 4
55define { i32, i1 } @cmpxchg_atomic_seq_cst_seq_cst_keep(ptr %ptr, i32 %old, i32 %in) {
56  %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
57  ret { i32, i1 } %val
58}
59
60; CHECK-LABEL: @cmpxchg_seq_cst_seq_cst_keep_left(
61; INTERESTING: syncscope("agent") seq_cst
62; RESULT: %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst monotonic, align 4
63define { i32, i1 } @cmpxchg_seq_cst_seq_cst_keep_left(ptr %ptr, i32 %old, i32 %in) {
64  %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
65  ret { i32, i1 } %val
66}
67
68; CHECK-LABEL: @cmpxchg_seq_cst_seq_cst_keep_right(
69; INTERESTING: seq_cst, align 4
70; RESULT: %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") monotonic seq_cst, align 4
71define { i32, i1 } @cmpxchg_seq_cst_seq_cst_keep_right(ptr %ptr, i32 %old, i32 %in) {
72  %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst, align 4
73  ret { i32, i1 } %val
74}
75
76; CHECK-LABEL: @cmpxchg_seq_cst_seq_cst_drop(
77; INTERESTING: = cmpxchg ptr
78; RESULT: %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") monotonic monotonic, align 4
79define { i32, i1 } @cmpxchg_seq_cst_seq_cst_drop(ptr %ptr, i32 %old, i32 %in) {
80  %val = cmpxchg ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
81  ret { i32, i1 } %val
82}
83