1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -march=aarch64 -run-pass=legalizer %s -o - | FileCheck %s
7 ; CHECK-LABEL: name: test_shift
8 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
9 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
10 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
11 ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
12 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]]
13 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
14 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
15 ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C1]](s32)
16 ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 24
17 ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C2]](s64)
18 ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32)
19 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32)
20 ; CHECK: $w0 = COPY [[COPY2]](s32)
21 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
22 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC2]], [[C]]
23 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
24 ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[TRUNC3]], [[C]]
25 ; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[AND2]], [[AND1]](s32)
26 ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[LSHR]](s32)
27 ; CHECK: $w0 = COPY [[COPY3]](s32)
28 ; CHECK: [[TRUNC4:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
29 ; CHECK: [[AND3:%[0-9]+]]:_(s32) = G_AND [[TRUNC4]], [[C]]
30 ; CHECK: [[TRUNC5:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
31 ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC5]], [[AND3]](s32)
32 ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SHL1]](s32)
33 ; CHECK: $w0 = COPY [[COPY4]](s32)
36 %2:_(s8) = G_TRUNC %0(s64)
37 %3:_(s8) = G_TRUNC %1(s64)
38 %4:_(s8) = G_ASHR %2, %3
39 %7:_(s32) = G_ANYEXT %4(s8)
41 %5:_(s8) = G_LSHR %2, %3
42 %8:_(s32) = G_ANYEXT %5(s8)
44 %6:_(s8) = G_SHL %2, %3
45 %9:_(s32) = G_ANYEXT %6(s8)
50 name: test_shl_i64_i32
53 ; CHECK-LABEL: name: test_shl_i64_i32
54 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
55 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
56 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY1]](s32)
57 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[ZEXT]](s64)
58 ; CHECK: $x0 = COPY [[SHL]](s64)
61 %2:_(s64) = G_SHL %0, %1
66 name: test_ashr_i64_i32
69 ; CHECK-LABEL: name: test_ashr_i64_i32
70 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
71 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
72 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY1]](s32)
73 ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[COPY]], [[ZEXT]](s64)
74 ; CHECK: $x0 = COPY [[ASHR]](s64)
77 %2:_(s64) = G_ASHR %0, %1
82 name: test_lshr_i64_i32
85 ; CHECK-LABEL: name: test_lshr_i64_i32
86 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
87 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
88 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY1]](s32)
89 ; CHECK: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[COPY]], [[ZEXT]](s64)
90 ; CHECK: $x0 = COPY [[LSHR]](s64)
93 %2:_(s64) = G_LSHR %0, %1
99 name: test_shl_s128_s128
102 ; CHECK-LABEL: name: test_shl_s128_s128
103 ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $q0
104 ; CHECK: [[COPY1:%[0-9]+]]:_(s128) = COPY $q1
105 ; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[COPY1]](s128)
106 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
107 ; CHECK: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY]](s128)
108 ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[TRUNC]], [[C]]
109 ; CHECK: [[SUB1:%[0-9]+]]:_(s64) = G_SUB [[C]], [[TRUNC]]
110 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
111 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[TRUNC]](s64), [[C]]
112 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
113 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[TRUNC]](s64), [[C1]]
114 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
115 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[UV]], [[TRUNC]](s64)
116 ; CHECK: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[UV]], [[SUB1]](s64)
117 ; CHECK: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[UV1]], [[TRUNC]](s64)
118 ; CHECK: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL1]]
119 ; CHECK: [[SHL2:%[0-9]+]]:_(s64) = G_SHL [[UV]], [[SUB]](s64)
120 ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[SHL]], [[C1]]
121 ; CHECK: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[OR]], [[SHL2]]
122 ; CHECK: [[SELECT2:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC2]](s1), [[UV1]], [[SELECT1]]
123 ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[SELECT]](s64), [[SELECT2]](s64)
124 ; CHECK: $q0 = COPY [[MV]](s128)
125 %0:_(s128) = COPY $q0
126 %1:_(s128) = COPY $q1
127 %2:_(s128) = G_SHL %0, %1
133 name: test_lshr_s128_s128
136 ; CHECK-LABEL: name: test_lshr_s128_s128
137 ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $q0
138 ; CHECK: [[COPY1:%[0-9]+]]:_(s128) = COPY $q1
139 ; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[COPY1]](s128)
140 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
141 ; CHECK: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY]](s128)
142 ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[TRUNC]], [[C]]
143 ; CHECK: [[SUB1:%[0-9]+]]:_(s64) = G_SUB [[C]], [[TRUNC]]
144 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
145 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[TRUNC]](s64), [[C]]
146 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
147 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[TRUNC]](s64), [[C1]]
148 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
149 ; CHECK: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[UV1]], [[TRUNC]](s64)
150 ; CHECK: [[LSHR1:%[0-9]+]]:_(s64) = G_LSHR [[UV]], [[TRUNC]](s64)
151 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[UV1]], [[SUB1]](s64)
152 ; CHECK: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR1]], [[SHL]]
153 ; CHECK: [[LSHR2:%[0-9]+]]:_(s64) = G_LSHR [[UV1]], [[SUB]](s64)
154 ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[OR]], [[LSHR2]]
155 ; CHECK: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC2]](s1), [[UV]], [[SELECT]]
156 ; CHECK: [[SELECT2:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[LSHR]], [[C1]]
157 ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[SELECT1]](s64), [[SELECT2]](s64)
158 ; CHECK: $q0 = COPY [[MV]](s128)
159 %0:_(s128) = COPY $q0
160 %1:_(s128) = COPY $q1
161 %2:_(s128) = G_LSHR %0, %1
167 name: test_ashr_s128_s128
170 ; CHECK-LABEL: name: test_ashr_s128_s128
171 ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $q0
172 ; CHECK: [[COPY1:%[0-9]+]]:_(s128) = COPY $q1
173 ; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[COPY1]](s128)
174 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
175 ; CHECK: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY]](s128)
176 ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[TRUNC]], [[C]]
177 ; CHECK: [[SUB1:%[0-9]+]]:_(s64) = G_SUB [[C]], [[TRUNC]]
178 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
179 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[TRUNC]](s64), [[C]]
180 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
181 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[TRUNC]](s64), [[C1]]
182 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
183 ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[TRUNC]](s64)
184 ; CHECK: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[UV]], [[TRUNC]](s64)
185 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[UV1]], [[SUB1]](s64)
186 ; CHECK: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL]]
187 ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 63
188 ; CHECK: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[C2]](s64)
189 ; CHECK: [[ASHR2:%[0-9]+]]:_(s64) = G_ASHR [[UV1]], [[SUB]](s64)
190 ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[OR]], [[ASHR2]]
191 ; CHECK: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC2]](s1), [[UV]], [[SELECT]]
192 ; CHECK: [[SELECT2:%[0-9]+]]:_(s64) = G_SELECT [[TRUNC1]](s1), [[ASHR]], [[ASHR1]]
193 ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[SELECT1]](s64), [[SELECT2]](s64)
194 ; CHECK: $q0 = COPY [[MV]](s128)
195 %0:_(s128) = COPY $q0
196 %1:_(s128) = COPY $q1
197 %2:_(s128) = G_ASHR %0, %1
203 name: test_ashr_v2i32
206 ; CHECK-LABEL: name: test_ashr_v2i32
207 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
208 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
209 ; CHECK: [[ASHR:%[0-9]+]]:_(<2 x s32>) = G_ASHR [[COPY]], [[COPY1]](<2 x s32>)
210 ; CHECK: $d0 = COPY [[ASHR]](<2 x s32>)
211 %0:_(<2 x s32>) = COPY $d0
212 %1:_(<2 x s32>) = COPY $d1
213 %2:_(<2 x s32>) = G_ASHR %0, %1
218 name: test_ashr_v4i32
221 ; CHECK-LABEL: name: test_ashr_v4i32
222 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
223 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
224 ; CHECK: [[ASHR:%[0-9]+]]:_(<4 x s32>) = G_ASHR [[COPY]], [[COPY1]](<4 x s32>)
225 ; CHECK: $q0 = COPY [[ASHR]](<4 x s32>)
226 %0:_(<4 x s32>) = COPY $q0
227 %1:_(<4 x s32>) = COPY $q1
228 %2:_(<4 x s32>) = G_ASHR %0, %1
238 ; CHECK-LABEL: name: shl_cimm_32
239 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
240 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
241 ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32)
242 ; CHECK: $w0 = COPY [[SHL]](s32)
243 ; CHECK: RET_ReallyLR implicit $w0
245 %1:_(s32) = G_CONSTANT i32 8
246 %2:_(s32) = G_SHL %0, %1(s32)
248 RET_ReallyLR implicit $w0
257 ; CHECK-LABEL: name: lshr_cimm_32
258 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
259 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
260 ; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]](s64)
261 ; CHECK: $w0 = COPY [[LSHR]](s32)
262 ; CHECK: RET_ReallyLR implicit $w0
264 %1:_(s32) = G_CONSTANT i32 8
265 %2:_(s32) = G_LSHR %0, %1(s32)
267 RET_ReallyLR implicit $w0
276 ; CHECK-LABEL: name: ashr_cimm_32
277 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
278 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
279 ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[COPY]], [[C]](s64)
280 ; CHECK: $w0 = COPY [[ASHR]](s32)
281 ; CHECK: RET_ReallyLR implicit $w0
283 %1:_(s32) = G_CONSTANT i32 8
284 %2:_(s32) = G_ASHR %0, %1(s32)
286 RET_ReallyLR implicit $w0