[SystemZ] Use "STC;MVC" for memset
[oota-llvm.git] / test / CodeGen / SystemZ / and-04.ll
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 ; There is no 64-bit AND instruction for a mask of 1.
6 ; FIXME: we ought to be able to require "ngr %r2, %r0", but at the moment,
7 ; two-address optimisations force "ngr %r0, %r2; lgr %r2, %r0" instead.
8 define i64 @f1(i64 %a) {
9 ; CHECK: f1:
10 ; CHECK: lghi %r0, 1
11 ; CHECK: ngr
12 ; CHECK: br %r14
13   %and = and i64 %a, 1
14   ret i64 %and
15 }
16
17 ; Likewise 0xfffe.
18 define i64 @f2(i64 %a) {
19 ; CHECK: f2:
20 ; CHECK: llill %r0, 65534
21 ; CHECK: ngr
22 ; CHECK: br %r14
23   %and = and i64 %a, 65534
24   ret i64 %and
25 }
26
27 ; ...but 0xffff is a 16-bit zero extension.
28 define i64 @f3(i64 %a) {
29 ; CHECK: f3:
30 ; CHECK: llghr %r2, %r2
31 ; CHECK: br %r14
32   %and = and i64 %a, 65535
33   ret i64 %and
34 }
35
36 ; Check the next value up, which again has no dedicated instruction.
37 define i64 @f4(i64 %a) {
38 ; CHECK: f4:
39 ; CHECK: llilh %r0, 1
40 ; CHECK: ngr
41 ; CHECK: br %r14
42   %and = and i64 %a, 65536
43   ret i64 %and
44 }
45
46 ; Check 0xfffffffe.
47 define i64 @f5(i64 %a) {
48 ; CHECK: f5:
49 ; CHECK: lilf %r0, 4294967294
50 ; CHECK: ngr
51 ; CHECK: br %r14
52   %and = and i64 %a, 4294967294
53   ret i64 %and
54 }
55
56 ; Check the next value up, which is a 32-bit zero extension.
57 define i64 @f6(i64 %a) {
58 ; CHECK: f6:
59 ; CHECK: llgfr %r2, %r2
60 ; CHECK: br %r14
61   %and = and i64 %a, 4294967295
62   ret i64 %and
63 }
64
65 ; Check the lowest useful NIHF value (0x00000001_ffffffff).
66 define i64 @f7(i64 %a) {
67 ; CHECK: f7:
68 ; CHECK: nihf %r2, 1
69 ; CHECK: br %r14
70   %and = and i64 %a, 8589934591
71   ret i64 %and
72 }
73
74 ; Check the low end of the NIHH range (0x0000ffff_ffffffff).
75 define i64 @f8(i64 %a) {
76 ; CHECK: f8:
77 ; CHECK: nihh %r2, 0
78 ; CHECK: br %r14
79   %and = and i64 %a, 281474976710655
80   ret i64 %and
81 }
82
83 ; Check the highest useful NIHH value (0xfffeffff_ffffffff).
84 define i64 @f9(i64 %a) {
85 ; CHECK: f9:
86 ; CHECK: nihh %r2, 65534
87 ; CHECK: br %r14
88   %and = and i64 %a, -281474976710657
89   ret i64 %and
90 }
91
92 ; Check the highest useful NIHF value (0xfffefffe_ffffffff).
93 define i64 @f10(i64 %a) {
94 ; CHECK: f10:
95 ; CHECK: nihf %r2, 4294901758
96 ; CHECK: br %r14
97   %and = and i64 %a, -281479271677953
98   ret i64 %and
99 }
100
101 ; Check the low end of the NIHL range (0xffff0000_ffffffff).
102 define i64 @f11(i64 %a) {
103 ; CHECK: f11:
104 ; CHECK: nihl %r2, 0
105 ; CHECK: br %r14
106   %and = and i64 %a, -281470681743361
107   ret i64 %and
108 }
109
110 ; Check the highest useful NIHL value (0xfffffffe_ffffffff).
111 define i64 @f12(i64 %a) {
112 ; CHECK: f12:
113 ; CHECK: nihl %r2, 65534
114 ; CHECK: br %r14
115   %and = and i64 %a, -4294967297
116   ret i64 %and
117 }
118
119 ; Check the low end of the NILF range (0xffffffff_00000000).
120 define i64 @f13(i64 %a) {
121 ; CHECK: f13:
122 ; CHECK: nilf %r2, 0
123 ; CHECK: br %r14
124   %and = and i64 %a, -4294967296
125   ret i64 %and
126 }
127
128 ; Check the low end of the NILH range (0xffffffff_0000ffff).
129 define i64 @f14(i64 %a) {
130 ; CHECK: f14:
131 ; CHECK: nilh %r2, 0
132 ; CHECK: br %r14
133   %and = and i64 %a, -4294901761
134   ret i64 %and
135 }
136
137 ; Check the next value up, which must use NILF.
138 define i64 @f15(i64 %a) {
139 ; CHECK: f15:
140 ; CHECK: nilf %r2, 65536
141 ; CHECK: br %r14
142   %and = and i64 %a, -4294901760
143   ret i64 %and
144 }
145
146 ; Check the maximum useful NILF value (0xffffffff_fffefffe).
147 define i64 @f16(i64 %a) {
148 ; CHECK: f16:
149 ; CHECK: nilf %r2, 4294901758
150 ; CHECK: br %r14
151   %and = and i64 %a, -65538
152   ret i64 %and
153 }
154
155 ; Check the highest useful NILH value, which is one greater than the above.
156 define i64 @f17(i64 %a) {
157 ; CHECK: f17:
158 ; CHECK: nilh %r2, 65534
159 ; CHECK: br %r14
160   %and = and i64 %a, -65537
161   ret i64 %and
162 }
163
164 ; Check the low end of the NILL range, which is one greater again.
165 define i64 @f18(i64 %a) {
166 ; CHECK: f18:
167 ; CHECK: nill %r2, 0
168 ; CHECK: br %r14
169   %and = and i64 %a, -65536
170   ret i64 %and
171 }
172
173 ; Check the highest useful NILL value.
174 define i64 @f19(i64 %a) {
175 ; CHECK: f19:
176 ; CHECK: nill %r2, 65534
177 ; CHECK: br %r14
178   %and = and i64 %a, -2
179   ret i64 %and
180 }