• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test 16-bit atomic NANDs.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT1
5; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT2
6
7; Check NAND of a variable.
8; - CHECK is for the main loop.
9; - CHECK-SHIFT1 makes sure that the negated shift count used by the second
10;   RLL is set up correctly.  The negation is independent of the NILL and L
11;   tested in CHECK.
12; - CHECK-SHIFT2 makes sure that %b is shifted into the high part of the word
13;   before being used, and that the low bits are set to 1.  This sequence is
14;   independent of the other loop prologue instructions.
15define i16 @f1(i16 *%src, i16 %b) {
16; CHECK-LABEL: f1:
17; CHECK: risbg [[RISBG:%r[1-9]+]], %r2, 0, 189, 0{{$}}
18; CHECK: sll %r2, 3
19; CHECK: l [[OLD:%r[0-9]+]], 0([[RISBG]])
20; CHECK: [[LABEL:\.[^:]*]]:
21; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0(%r2)
22; CHECK: nr [[ROT]], %r3
23; CHECK: xilf [[ROT]], 4294901760
24; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0({{%r[1-9]+}})
25; CHECK: cs [[OLD]], [[NEW]], 0([[RISBG]])
26; CHECK: jl [[LABEL]]
27; CHECK: rll %r2, [[OLD]], 16(%r2)
28; CHECK: br %r14
29;
30; CHECK-SHIFT1-LABEL: f1:
31; CHECK-SHIFT1: sll %r2, 3
32; CHECK-SHIFT1: lcr [[NEGSHIFT:%r[1-9]+]], %r2
33; CHECK-SHIFT1: rll
34; CHECK-SHIFT1: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])
35; CHECK-SHIFT1: rll
36; CHECK-SHIFT1: br %r14
37;
38; CHECK-SHIFT2-LABEL: f1:
39; CHECK-SHIFT2: sll %r3, 16
40; CHECK-SHIFT2: oill %r3, 65535
41; CHECK-SHIFT2: rll
42; CHECK-SHIFT2: nr {{%r[0-9]+}}, %r3
43; CHECK-SHIFT2: rll
44; CHECK-SHIFT2: rll
45; CHECK-SHIFT2: br %r14
46  %res = atomicrmw nand i16 *%src, i16 %b seq_cst
47  ret i16 %res
48}
49
50; Check the minimum signed value.  We AND the rotated word with 0x8000ffff.
51define i16 @f2(i16 *%src) {
52; CHECK-LABEL: f2:
53; CHECK: risbg [[RISBG:%r[1-9]+]], %r2, 0, 189, 0{{$}}
54; CHECK: sll %r2, 3
55; CHECK: l [[OLD:%r[0-9]+]], 0([[RISBG]])
56; CHECK: [[LABEL:\.[^:]*]]:
57; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0(%r2)
58; CHECK: nilh [[ROT]], 32768
59; CHECK: xilf [[ROT]], 4294901760
60; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0([[NEGSHIFT:%r[1-9]+]])
61; CHECK: cs [[OLD]], [[NEW]], 0([[RISBG]])
62; CHECK: jl [[LABEL]]
63; CHECK: rll %r2, [[OLD]], 16(%r2)
64; CHECK: br %r14
65;
66; CHECK-SHIFT1-LABEL: f2:
67; CHECK-SHIFT1: sll %r2, 3
68; CHECK-SHIFT1: lcr [[NEGSHIFT:%r[1-9]+]], %r2
69; CHECK-SHIFT1: rll
70; CHECK-SHIFT1: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])
71; CHECK-SHIFT1: rll
72; CHECK-SHIFT1: br %r14
73;
74; CHECK-SHIFT2-LABEL: f2:
75; CHECK-SHIFT2: br %r14
76  %res = atomicrmw nand i16 *%src, i16 -32768 seq_cst
77  ret i16 %res
78}
79
80; Check NANDs of -2 (-1 isn't useful).  We AND the rotated word with 0xfffeffff.
81define i16 @f3(i16 *%src) {
82; CHECK-LABEL: f3:
83; CHECK: nilh [[ROT]], 65534
84; CHECK: xilf [[ROT]], 4294901760
85; CHECK: br %r14
86;
87; CHECK-SHIFT1-LABEL: f3:
88; CHECK-SHIFT1: br %r14
89; CHECK-SHIFT2-LABEL: f3:
90; CHECK-SHIFT2: br %r14
91  %res = atomicrmw nand i16 *%src, i16 -2 seq_cst
92  ret i16 %res
93}
94
95; Check ANDs of 1.  We AND the rotated word with 0x0001ffff.
96define i16 @f4(i16 *%src) {
97; CHECK-LABEL: f4:
98; CHECK: nilh [[ROT]], 1
99; CHECK: xilf [[ROT]], 4294901760
100; CHECK: br %r14
101;
102; CHECK-SHIFT1-LABEL: f4:
103; CHECK-SHIFT1: br %r14
104; CHECK-SHIFT2-LABEL: f4:
105; CHECK-SHIFT2: br %r14
106  %res = atomicrmw nand i16 *%src, i16 1 seq_cst
107  ret i16 %res
108}
109
110; Check the maximum signed value.  We AND the rotated word with 0x7fffffff.
111define i16 @f5(i16 *%src) {
112; CHECK-LABEL: f5:
113; CHECK: nilh [[ROT]], 32767
114; CHECK: xilf [[ROT]], 4294901760
115; CHECK: br %r14
116;
117; CHECK-SHIFT1-LABEL: f5:
118; CHECK-SHIFT1: br %r14
119; CHECK-SHIFT2-LABEL: f5:
120; CHECK-SHIFT2: br %r14
121  %res = atomicrmw nand i16 *%src, i16 32767 seq_cst
122  ret i16 %res
123}
124
125; Check NANDs of a large unsigned value.  We AND the rotated word with
126; 0xfffdffff.
127define i16 @f6(i16 *%src) {
128; CHECK-LABEL: f6:
129; CHECK: nilh [[ROT]], 65533
130; CHECK: xilf [[ROT]], 4294901760
131; CHECK: br %r14
132;
133; CHECK-SHIFT1-LABEL: f6:
134; CHECK-SHIFT1: br %r14
135; CHECK-SHIFT2-LABEL: f6:
136; CHECK-SHIFT2: br %r14
137  %res = atomicrmw nand i16 *%src, i16 65533 seq_cst
138  ret i16 %res
139}
140