Skip to content

Commit 7fd3ed9

Browse files
committed
[SystemZ] Add atomicrmw tests for i128 (NFC).
Review: Ulrich Weigand
1 parent 7aa2708 commit 7fd3ed9

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
; Test i128 atomicrmw operations.
2+
;
3+
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 | FileCheck %s
4+
5+
; Check register exchange.
6+
define i128 @f1(i128 %dummy, ptr %src, i128 %b) {
7+
; CHECK-LABEL: f1:
8+
; CHECK: brasl %r14, __sync_lock_test_and_set_16@PLT
9+
; CHECK: br %r14
10+
%res = atomicrmw xchg ptr %src, i128 %b seq_cst
11+
ret i128 %res
12+
}
13+
14+
; Check addition of a variable.
15+
define i128 @f2(i128 %dummy, ptr %src, i128 %b) {
16+
; CHECK-LABEL: f2:
17+
; CHECK: brasl %r14, __sync_fetch_and_add_16@PLT
18+
; CHECK: br %r14
19+
%res = atomicrmw add ptr %src, i128 %b seq_cst
20+
ret i128 %res
21+
}
22+
23+
; Check subtraction of a variable.
24+
define i128 @f3(i128 %dummy, ptr %src, i128 %b) {
25+
; CHECK-LABEL: f3:
26+
; CHECK: brasl %r14, __sync_fetch_and_sub_16@PLT
27+
; CHECK: br %r14
28+
%res = atomicrmw sub ptr %src, i128 %b seq_cst
29+
ret i128 %res
30+
}
31+
32+
; Check AND of a variable.
33+
define i128 @f4(i128 %dummy, ptr %src, i128 %b) {
34+
; CHECK-LABEL: f4:
35+
; CHECK: brasl %r14, __sync_fetch_and_and_16@PLT
36+
; CHECK: br %r14
37+
%res = atomicrmw and ptr %src, i128 %b seq_cst
38+
ret i128 %res
39+
}
40+
41+
; Check NAND of a variable.
42+
define i128 @f5(i128 %dummy, ptr %src, i128 %b) {
43+
; CHECK-LABEL: f5:
44+
; CHECK: brasl %r14, __sync_fetch_and_nand_16@PLT
45+
; CHECK: br %r14
46+
%res = atomicrmw nand ptr %src, i128 %b seq_cst
47+
ret i128 %res
48+
}
49+
50+
; Check OR of a variable.
51+
define i128 @f6(i128 %dummy, ptr %src, i128 %b) {
52+
; CHECK-LABEL: f6:
53+
; CHECK: brasl %r14, __sync_fetch_and_or_16@PLT
54+
; CHECK: br %r14
55+
%res = atomicrmw or ptr %src, i128 %b seq_cst
56+
ret i128 %res
57+
}
58+
59+
; Check XOR of a variable.
60+
define i128 @f7(i128 %dummy, ptr %src, i128 %b) {
61+
; CHECK-LABEL: f7:
62+
; CHECK: brasl %r14, __sync_fetch_and_xor_16@PLT
63+
; CHECK: br %r14
64+
%res = atomicrmw xor ptr %src, i128 %b seq_cst
65+
ret i128 %res
66+
}
67+
68+
; Check signed minimum.
69+
define i128 @f8(i128 %dummy, ptr %src, i128 %b) {
70+
; CHECK-LABEL: f8:
71+
; CHECK: brasl %r14, __sync_fetch_and_min_16@PLT
72+
; CHECK: br %r14
73+
%res = atomicrmw min ptr %src, i128 %b seq_cst
74+
ret i128 %res
75+
}
76+
77+
; Check signed maximum.
78+
define i128 @f9(i128 %dummy, ptr %src, i128 %b) {
79+
; CHECK-LABEL: f9:
80+
; CHECK: brasl %r14, __sync_fetch_and_max_16@PLT
81+
; CHECK: br %r14
82+
%res = atomicrmw max ptr %src, i128 %b seq_cst
83+
ret i128 %res
84+
}
85+
86+
; Check unsigned minimum.
87+
define i128 @f10(i128 %dummy, ptr %src, i128 %b) {
88+
; CHECK-LABEL: f10:
89+
; CHECK: brasl %r14, __sync_fetch_and_umin_16@PLT
90+
; CHECK: br %r14
91+
%res = atomicrmw umin ptr %src, i128 %b seq_cst
92+
ret i128 %res
93+
}
94+
95+
; Check unsigned maximum.
96+
define i128 @f11(i128 %dummy, ptr %src, i128 %b) {
97+
; CHECK-LABEL: f11:
98+
; CHECK: brasl %r14, __sync_fetch_and_umax_16@PLT
99+
; CHECK: br %r14
100+
%res = atomicrmw umax ptr %src, i128 %b seq_cst
101+
ret i128 %res
102+
}
103+

llvm/test/CodeGen/SystemZ/cmpxchg-06.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; Test 64-bit compare and swap.
1+
; Test 128-bit compare and swap.
22
;
33
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
44

0 commit comments

Comments
 (0)