• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test 64-bit ANDs in which the second operand is constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Use RISBG for a single bit.
6define i64 @f1(i64 %a) {
7; CHECK-LABEL: f1:
8; CHECK: risbg %r2, %r2, 63, 191, 0
9; CHECK: br %r14
10  %and = and i64 %a, 1
11  ret i64 %and
12}
13
14; Likewise 0xfffe.
15define i64 @f2(i64 %a) {
16; CHECK-LABEL: f2:
17; CHECK: risbg %r2, %r2, 48, 190, 0
18; CHECK: br %r14
19  %and = and i64 %a, 65534
20  ret i64 %and
21}
22
23; ...but 0xffff is a 16-bit zero extension.
24define i64 @f3(i64 %a, i64 %b) {
25; CHECK-LABEL: f3:
26; CHECK: llghr %r2, %r3
27; CHECK: br %r14
28  %and = and i64 %b, 65535
29  ret i64 %and
30}
31
32; Check the next value up, which can again use RISBG.
33define i64 @f4(i64 %a) {
34; CHECK-LABEL: f4:
35; CHECK: risbg %r2, %r2, 47, 175, 0
36; CHECK: br %r14
37  %and = and i64 %a, 65536
38  ret i64 %and
39}
40
41; Check 0xfffffffe, which can also use RISBG.
42define i64 @f5(i64 %a) {
43; CHECK-LABEL: f5:
44; CHECK: risbg %r2, %r2, 32, 190, 0
45; CHECK: br %r14
46  %and = and i64 %a, 4294967294
47  ret i64 %and
48}
49
50; Check the next value up, which is a 32-bit zero extension.
51define i64 @f6(i64 %a, i64 %b) {
52; CHECK-LABEL: f6:
53; CHECK: llgfr %r2, %r3
54; CHECK: br %r14
55  %and = and i64 %b, 4294967295
56  ret i64 %and
57}
58
59; Check the lowest useful NIHF value (0x00000001_ffffffff).
60define i64 @f7(i64 %a) {
61; CHECK-LABEL: f7:
62; CHECK: nihf %r2, 1
63; CHECK: br %r14
64  %and = and i64 %a, 8589934591
65  ret i64 %and
66}
67
68; ...but RISBG can be used if a three-address form is useful.
69define i64 @f8(i64 %a, i64 %b) {
70; CHECK-LABEL: f8:
71; CHECK: risbg %r2, %r3, 31, 191, 0
72; CHECK: br %r14
73  %and = and i64 %b, 8589934591
74  ret i64 %and
75}
76
77; Check the lowest NIHH value outside the RISBG range (0x0002ffff_ffffffff).
78define i64 @f9(i64 %a) {
79; CHECK-LABEL: f9:
80; CHECK: nihh %r2, 2
81; CHECK: br %r14
82  %and = and i64 %a, 844424930131967
83  ret i64 %and
84}
85
86; Check the highest NIHH value outside the RISBG range (0xfffaffff_ffffffff).
87define i64 @f10(i64 %a) {
88; CHECK-LABEL: f10:
89; CHECK: nihh %r2, 65530
90; CHECK: br %r14
91  %and = and i64 %a, -1407374883553281
92  ret i64 %and
93}
94
95; Check the highest useful NIHF value (0xfffefffe_ffffffff).
96define i64 @f11(i64 %a) {
97; CHECK-LABEL: f11:
98; CHECK: nihf %r2, 4294901758
99; CHECK: br %r14
100  %and = and i64 %a, -281479271677953
101  ret i64 %and
102}
103
104; Check the lowest NIHL value outside the RISBG range (0xffff0002_ffffffff).
105define i64 @f12(i64 %a) {
106; CHECK-LABEL: f12:
107; CHECK: nihl %r2, 2
108; CHECK: br %r14
109  %and = and i64 %a, -281462091808769
110  ret i64 %and
111}
112
113; Check the highest NIHL value outside the RISBG range (0xfffffffa_ffffffff).
114define i64 @f13(i64 %a) {
115; CHECK-LABEL: f13:
116; CHECK: nihl %r2, 65530
117; CHECK: br %r14
118  %and = and i64 %a, -21474836481
119  ret i64 %and
120}
121
122; Check the lowest NILF value outside the RISBG range (0xffffffff_00000002).
123define i64 @f14(i64 %a) {
124; CHECK-LABEL: f14:
125; CHECK: nilf %r2, 2
126; CHECK: br %r14
127  %and = and i64 %a, -4294967294
128  ret i64 %and
129}
130
131; Check the lowest NILH value outside the RISBG range (0xffffffff_0002ffff).
132define i64 @f15(i64 %a) {
133; CHECK-LABEL: f15:
134; CHECK: nilh %r2, 2
135; CHECK: br %r14
136  %and = and i64 %a, -4294770689
137  ret i64 %and
138}
139
140; Check the next value up, which must use NILF.
141define i64 @f16(i64 %a) {
142; CHECK-LABEL: f16:
143; CHECK: nilf %r2, 196608
144; CHECK: br %r14
145  %and = and i64 %a, -4294770688
146  ret i64 %and
147}
148
149; Check the highest NILH value outside the RISBG range (0xffffffff_fffaffff).
150define i64 @f17(i64 %a) {
151; CHECK-LABEL: f17:
152; CHECK: nilh %r2, 65530
153; CHECK: br %r14
154  %and = and i64 %a, -327681
155  ret i64 %and
156}
157
158; Check the maximum useful NILF value (0xffffffff_fffefffe).
159define i64 @f18(i64 %a) {
160; CHECK-LABEL: f18:
161; CHECK: nilf %r2, 4294901758
162; CHECK: br %r14
163  %and = and i64 %a, -65538
164  ret i64 %and
165}
166
167; Check the lowest NILL value outside the RISBG range (0xffffffff_ffff0002).
168define i64 @f19(i64 %a) {
169; CHECK-LABEL: f19:
170; CHECK: nill %r2, 2
171; CHECK: br %r14
172  %and = and i64 %a, -65534
173  ret i64 %and
174}
175
176; Check the highest NILL value outside the RISBG range.
177define i64 @f20(i64 %a) {
178; CHECK-LABEL: f20:
179; CHECK: nill %r2, 65530
180; CHECK: br %r14
181  %and = and i64 %a, -6
182  ret i64 %and
183}
184