blob: 8d813a1402493a07456d9bed91ce442d3dcc31c7 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 32-bit atomic ANDs.
2;
Richard Sandiford0175b4a2013-07-19 16:21:55 +00003; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00004
5; Check ANDs of a variable.
6define i32 @f1(i32 %dummy, i32 *%src, i32 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; CHECK: l %r2, 0(%r3)
9; CHECK: [[LABEL:\.[^ ]*]]:
10; CHECK: lr %r0, %r2
11; CHECK: nr %r0, %r4
12; CHECK: cs %r2, %r0, 0(%r3)
Richard Sandiford3d768e32013-07-31 12:30:20 +000013; CHECK: jl [[LABEL]]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000014; CHECK: br %r14
15 %res = atomicrmw and i32 *%src, i32 %b seq_cst
16 ret i32 %res
17}
18
19; Check ANDs of 1.
20define i32 @f2(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000021; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022; CHECK: l %r2, 0(%r3)
23; CHECK: [[LABEL:\.[^ ]*]]:
24; CHECK: lr %r0, %r2
25; CHECK: nilf %r0, 1
26; CHECK: cs %r2, %r0, 0(%r3)
Richard Sandiford3d768e32013-07-31 12:30:20 +000027; CHECK: jl [[LABEL]]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000028; CHECK: br %r14
29 %res = atomicrmw and i32 *%src, i32 1 seq_cst
30 ret i32 %res
31}
32
33; Check ANDs of the low end of the NILH range.
34define i32 @f3(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000035; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000036; CHECK: nilh %r0, 0
37; CHECK: br %r14
38 %res = atomicrmw and i32 *%src, i32 65535 seq_cst
39 ret i32 %res
40}
41
42; Check the next value up, which must use NILF.
43define i32 @f4(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000044; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000045; CHECK: nilf %r0, 65536
46; CHECK: br %r14
47 %res = atomicrmw and i32 *%src, i32 65536 seq_cst
48 ret i32 %res
49}
50
51; Check the largest useful NILL value.
52define i32 @f5(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000053; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000054; CHECK: nill %r0, 65534
55; CHECK: br %r14
56 %res = atomicrmw and i32 *%src, i32 -2 seq_cst
57 ret i32 %res
58}
59
60; Check the low end of the NILL range.
61define i32 @f6(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000062; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000063; CHECK: nill %r0, 0
64; CHECK: br %r14
65 %res = atomicrmw and i32 *%src, i32 -65536 seq_cst
66 ret i32 %res
67}
68
69; Check the largest useful NILH value, which is one less than the above.
70define i32 @f7(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000071; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000072; CHECK: nilh %r0, 65534
73; CHECK: br %r14
74 %res = atomicrmw and i32 *%src, i32 -65537 seq_cst
75 ret i32 %res
76}
77
78; Check the highest useful NILF value, which is one less than the above.
79define i32 @f8(i32 %dummy, i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000080; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000081; CHECK: nilf %r0, 4294901758
82; CHECK: br %r14
83 %res = atomicrmw and i32 *%src, i32 -65538 seq_cst
84 ret i32 %res
85}