blob: 91fe639cd726ae800c9dbf2efddb989f4c2b630a [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 64-bit atomic NANDs.
2;
Richard Sandifordc57e5862013-07-19 16:24:22 +00003; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00004
5; Check NANDs of a variable.
6define i64 @f1(i64 %dummy, i64 *%src, i64 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; CHECK: lg %r2, 0(%r3)
9; CHECK: [[LABEL:\.[^:]*]]:
10; CHECK: lgr %r0, %r2
11; CHECK: ngr %r0, %r4
12; CHECK: lcgr %r0, %r0
13; CHECK: aghi %r0, -1
14; CHECK: csg %r2, %r0, 0(%r3)
Richard Sandiford3d768e32013-07-31 12:30:20 +000015; CHECK: jl [[LABEL]]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000016; CHECK: br %r14
17 %res = atomicrmw nand i64 *%src, i64 %b seq_cst
18 ret i64 %res
19}
20
Richard Sandiford6a06ba32013-07-31 11:36:35 +000021; Check NANDs of 1, which are done using a register. (We could use RISBG
22; instead, but that isn't implemented yet.)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000023define i64 @f2(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000024; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000025; CHECK: ngr
26; CHECK: br %r14
27 %res = atomicrmw nand i64 *%src, i64 1 seq_cst
28 ret i64 %res
29}
30
Richard Sandiford6a06ba32013-07-31 11:36:35 +000031; Check the equivalent of NIHF with 1, which can use RISBG instead.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000032define i64 @f3(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000033; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000034; CHECK: lg %r2, 0(%r3)
35; CHECK: [[LABEL:\.[^:]*]]:
Richard Sandiford6a06ba32013-07-31 11:36:35 +000036; CHECK: risbg %r0, %r2, 31, 191, 0
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000037; CHECK: lcgr %r0, %r0
38; CHECK: aghi %r0, -1
39; CHECK: csg %r2, %r0, 0(%r3)
Richard Sandiford3d768e32013-07-31 12:30:20 +000040; CHECK: jl [[LABEL]]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000041; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +000042 %res = atomicrmw nand i64 *%src, i64 8589934591 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000043 ret i64 %res
44}
45
Richard Sandiford6a06ba32013-07-31 11:36:35 +000046; Check the lowest NIHF value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000047define i64 @f4(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000048; CHECK-LABEL: f4:
Richard Sandiford6a06ba32013-07-31 11:36:35 +000049; CHECK: lg %r2, 0(%r3)
50; CHECK: [[LABEL:\.[^:]*]]:
51; CHECK: lgr %r0, %r2
52; CHECK: nihf %r0, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000053; CHECK: lcgr %r0, %r0
54; CHECK: aghi %r0, -1
Richard Sandiford6a06ba32013-07-31 11:36:35 +000055; CHECK: csg %r2, %r0, 0(%r3)
Richard Sandiford3d768e32013-07-31 12:30:20 +000056; CHECK: jl [[LABEL]]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000057; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +000058 %res = atomicrmw nand i64 *%src, i64 12884901887 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000059 ret i64 %res
60}
61
62; Check the next value up, which must use a register.
Richard Sandiford6a06ba32013-07-31 11:36:35 +000063define i64 @f5(i64 %dummy, i64 *%src) {
64; CHECK-LABEL: f5:
65; CHECK: ngr
66; CHECK: br %r14
67 %res = atomicrmw nand i64 *%src, i64 12884901888 seq_cst
68 ret i64 %res
69}
70
71; Check the lowest NIHH value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000072define i64 @f6(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000073; CHECK-LABEL: f6:
Richard Sandiford6a06ba32013-07-31 11:36:35 +000074; CHECK: nihh {{%r[0-5]}}, 2
75; CHECK: br %r14
76 %res = atomicrmw nand i64 *%src, i64 844424930131967 seq_cst
77 ret i64 %res
78}
79
80; Check the next value up, which must use a register.
81define i64 @f7(i64 %dummy, i64 *%src) {
82; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000083; CHECK: ngr
84; CHECK: br %r14
85 %res = atomicrmw nand i64 *%src, i64 281474976710656 seq_cst
86 ret i64 %res
87}
88
Richard Sandiford6a06ba32013-07-31 11:36:35 +000089; Check the highest NILL value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000090define i64 @f8(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000091; CHECK-LABEL: f8:
Richard Sandiford6a06ba32013-07-31 11:36:35 +000092; CHECK: nill {{%r[0-5]}}, 65530
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000093; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +000094 %res = atomicrmw nand i64 *%src, i64 -6 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000095 ret i64 %res
96}
97
Richard Sandiford6a06ba32013-07-31 11:36:35 +000098; Check the lowest NILL value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000099define i64 @f9(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000100; CHECK-LABEL: f9:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000101; CHECK: nill {{%r[0-5]}}, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000102; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000103 %res = atomicrmw nand i64 *%src, i64 -65534 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000104 ret i64 %res
105}
106
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000107; Check the highest useful NILF value.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000108define i64 @f10(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000109; CHECK-LABEL: f10:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000110; CHECK: nilf {{%r[0-5]}}, 4294901758
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000111; CHECK: br %r14
112 %res = atomicrmw nand i64 *%src, i64 -65538 seq_cst
113 ret i64 %res
114}
115
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000116; Check the highest NILH value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000117define i64 @f11(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000118; CHECK-LABEL: f11:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000119; CHECK: nilh {{%r[0-5]}}, 65530
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000120; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000121 %res = atomicrmw nand i64 *%src, i64 -327681 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000122 ret i64 %res
123}
124
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000125; Check the lowest NILH value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000126define i64 @f12(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000127; CHECK-LABEL: f12:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000128; CHECK: nilh {{%r[0-5]}}, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000129; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000130 %res = atomicrmw nand i64 *%src, i64 -4294770689 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000131 ret i64 %res
132}
133
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000134; Check the lowest NILF value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000135define i64 @f13(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000136; CHECK-LABEL: f13:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000137; CHECK: nilf {{%r[0-5]}}, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000138; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000139 %res = atomicrmw nand i64 *%src, i64 -4294967294 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000140 ret i64 %res
141}
142
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000143; Check the highest NIHL value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000144define i64 @f14(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000145; CHECK-LABEL: f14:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000146; CHECK: nihl {{%r[0-5]}}, 65530
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000147; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000148 %res = atomicrmw nand i64 *%src, i64 -21474836481 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000149 ret i64 %res
150}
151
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000152; Check the lowest NIHL value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000153define i64 @f15(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000154; CHECK-LABEL: f15:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000155; CHECK: nihl {{%r[0-5]}}, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000156; CHECK: br %r14
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000157 %res = atomicrmw nand i64 *%src, i64 -281462091808769 seq_cst
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000158 ret i64 %res
159}
160
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000161; Check the highest NIHH value outside the range of RISBG.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000162define i64 @f16(i64 %dummy, i64 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000163; CHECK-LABEL: f16:
Richard Sandiford6a06ba32013-07-31 11:36:35 +0000164; CHECK: nihh {{%r[0-5]}}, 65530
165; CHECK: br %r14
166 %res = atomicrmw nand i64 *%src, i64 -1407374883553281 seq_cst
167 ret i64 %res
168}
169
170; Check the highest useful NIHF value.
171define i64 @f17(i64 %dummy, i64 *%src) {
172; CHECK-LABEL: f17:
173; CHECK: nihf {{%r[0-5]}}, 4294901758
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000174; CHECK: br %r14
175 %res = atomicrmw nand i64 *%src, i64 -281479271677953 seq_cst
176 ret i64 %res
177}