1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
| ; RUN: llc --verify-machineinstrs -mtriple=thumbv8.1-m.main-none-eabi -mattr=+mve %s -o - | FileCheck %s -check-prefix=CHECK --check-prefix=CHECK-MVE
; RUN: llc --verify-machineinstrs -mtriple=thumbv8.1-m.main-none-eabi %s -o - | FileCheck %s -check-prefix=CHECK --check-prefix=CHECK-NON-MVE
define i64 @shift_left_reg(i64 %x, i64 %y) {
; CHECK-MVE-LABEL: shift_left_reg:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: lsll r0, r1, r2
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_left_reg:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: .save {r7, lr}
; CHECK-NON-MVE-NEXT: push {r7, lr}
; CHECK-NON-MVE-NEXT: bl __aeabi_llsl
; CHECK-NON-MVE-NEXT: pop {r7}
; CHECK-NON-MVE-NEXT: pop {r2}
; CHECK-NON-MVE-NEXT: bx r2
entry:
%shl = shl i64 %x, %y
ret i64 %shl
}
define i64 @shift_left_imm(i64 %x) {
; CHECK-MVE-LABEL: shift_left_imm:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: lsll r0, r1, #3
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_left_imm:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: lsrs r2, r0, #29
; CHECK-NON-MVE-NEXT: lsls r1, r1, #3
; CHECK-NON-MVE-NEXT: adds r1, r1, r2
; CHECK-NON-MVE-NEXT: lsls r0, r0, #3
; CHECK-NON-MVE-NEXT: bx lr
entry:
%shl = shl i64 %x, 3
ret i64 %shl
}
define i64 @shift_left_imm_big(i64 %x) {
; CHECK-LABEL: shift_left_imm_big:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: lsls r1, r0, #16
; CHECK-NEXT: movs r0, #0
; CHECK-NEXT: bx lr
entry:
%shl = shl i64 %x, 48
ret i64 %shl
}
define i64 @shift_left_imm_big2(i64 %x) {
; CHECK-MVE-LABEL: shift_left_imm_big2:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: mov r1, r0
; CHECK-MVE-NEXT: movs r0, #0
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_left_imm_big2:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: movs r1, r0
; CHECK-NON-MVE-NEXT: movs r0, #0
; CHECK-NON-MVE-NEXT: bx lr
entry:
%shl = shl i64 %x, 32
ret i64 %shl
}
define i64 @shift_left_imm_big3(i64 %x) {
; CHECK-LABEL: shift_left_imm_big3:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: lsls r1, r0, #1
; CHECK-NEXT: movs r0, #0
; CHECK-NEXT: bx lr
entry:
%shl = shl i64 %x, 33
ret i64 %shl
}
define i64 @shift_right_reg(i64 %x, i64 %y) {
; CHECK-MVE-LABEL: shift_right_reg:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: rsbs r2, r2, #0
; CHECK-MVE-NEXT: lsll r0, r1, r2
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_right_reg:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: .save {r7, lr}
; CHECK-NON-MVE-NEXT: push {r7, lr}
; CHECK-NON-MVE-NEXT: bl __aeabi_llsr
; CHECK-NON-MVE-NEXT: pop {r7}
; CHECK-NON-MVE-NEXT: pop {r2}
; CHECK-NON-MVE-NEXT: bx r2
entry:
%shr = lshr i64 %x, %y
ret i64 %shr
}
define i64 @shift_right_imm(i64 %x) {
; CHECK-MVE-LABEL: shift_right_imm:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: lsrl r0, r1, #3
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_right_imm:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: lsls r2, r1, #29
; CHECK-NON-MVE-NEXT: lsrs r0, r0, #3
; CHECK-NON-MVE-NEXT: adds r0, r0, r2
; CHECK-NON-MVE-NEXT: lsrs r1, r1, #3
; CHECK-NON-MVE-NEXT: bx lr
entry:
%shr = lshr i64 %x, 3
ret i64 %shr
}
define i64 @shift_right_imm_big(i64 %x) {
; CHECK-LABEL: shift_right_imm_big:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: lsrs r0, r1, #16
; CHECK-NEXT: movs r1, #0
; CHECK-NEXT: bx lr
entry:
%shr = lshr i64 %x, 48
ret i64 %shr
}
define i64 @shift_right_imm_big2(i64 %x) {
; CHECK-MVE-LABEL: shift_right_imm_big2:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: mov r0, r1
; CHECK-MVE-NEXT: movs r1, #0
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_right_imm_big2:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: movs r0, r1
; CHECK-NON-MVE-NEXT: movs r1, #0
; CHECK-NON-MVE-NEXT: bx lr
entry:
%shr = lshr i64 %x, 32
ret i64 %shr
}
define i64 @shift_right_imm_big3(i64 %x) {
; CHECK-LABEL: shift_right_imm_big3:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: lsrs r0, r1, #1
; CHECK-NEXT: movs r1, #0
; CHECK-NEXT: bx lr
entry:
%shr = lshr i64 %x, 33
ret i64 %shr
}
define i64 @shift_arithmetic_right_reg(i64 %x, i64 %y) {
; CHECK-MVE-LABEL: shift_arithmetic_right_reg:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: asrl r0, r1, r2
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_arithmetic_right_reg:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: .save {r7, lr}
; CHECK-NON-MVE-NEXT: push {r7, lr}
; CHECK-NON-MVE-NEXT: bl __aeabi_lasr
; CHECK-NON-MVE-NEXT: pop {r7}
; CHECK-NON-MVE-NEXT: pop {r2}
; CHECK-NON-MVE-NEXT: bx r2
entry:
%shr = ashr i64 %x, %y
ret i64 %shr
}
define i64 @shift_arithmetic_right_imm(i64 %x) {
; CHECK-MVE-LABEL: shift_arithmetic_right_imm:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: asrl r0, r1, #3
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: shift_arithmetic_right_imm:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: lsls r2, r1, #29
; CHECK-NON-MVE-NEXT: lsrs r0, r0, #3
; CHECK-NON-MVE-NEXT: adds r0, r0, r2
; CHECK-NON-MVE-NEXT: asrs r1, r1, #3
; CHECK-NON-MVE-NEXT: bx lr
entry:
%shr = ashr i64 %x, 3
ret i64 %shr
}
%struct.bar = type { i16, i8, [5 x i8] }
define arm_aapcs_vfpcc void @fn1(%struct.bar* nocapture %a) {
; CHECK-MVE-LABEL: fn1:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: ldr r2, [r0, #4]
; CHECK-MVE-NEXT: movs r1, #0
; CHECK-MVE-NEXT: lsll r2, r1, #8
; CHECK-MVE-NEXT: strb r1, [r0, #7]
; CHECK-MVE-NEXT: str.w r2, [r0, #3]
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: fn1:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: ldr r1, [r0, #4]
; CHECK-NON-MVE-NEXT: lsls r2, r1, #8
; CHECK-NON-MVE-NEXT: movs r3, #3
; CHECK-NON-MVE-NEXT: str r2, [r0, r3]
; CHECK-NON-MVE-NEXT: adds r0, r0, #3
; CHECK-NON-MVE-NEXT: lsrs r1, r1, #24
; CHECK-NON-MVE-NEXT: strb r1, [r0, #4]
; CHECK-NON-MVE-NEXT: bx lr
entry:
%carey = getelementptr inbounds %struct.bar, %struct.bar* %a, i32 0, i32 2
%0 = bitcast [5 x i8]* %carey to i40*
%bf.load = load i40, i40* %0, align 1
%bf.clear = and i40 %bf.load, -256
store i40 %bf.clear, i40* %0, align 1
ret void
}
%struct.a = type { i96 }
define void @lsll_128bit_shift(%struct.a* nocapture %x) local_unnamed_addr #0 {
; CHECK-MVE-LABEL: lsll_128bit_shift:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: movs r1, #0
; CHECK-MVE-NEXT: strd r1, r1, [r0]
; CHECK-MVE-NEXT: str r1, [r0, #8]
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: lsll_128bit_shift:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: movs r1, #0
; CHECK-NON-MVE-NEXT: str r1, [r0]
; CHECK-NON-MVE-NEXT: str r1, [r0, #4]
; CHECK-NON-MVE-NEXT: str r1, [r0, #8]
; CHECK-NON-MVE-NEXT: bx lr
entry:
%0 = bitcast %struct.a* %x to i128*
%bf.load = load i128, i128* %0, align 8
%bf.clear4 = and i128 %bf.load, -79228162514264337593543950336
store i128 %bf.clear4, i128* %0, align 8
ret void
}
%struct.b = type { i184 }
define void @lsll_256bit_shift(%struct.b* nocapture %x) local_unnamed_addr #0 {
; CHECK-MVE-LABEL: lsll_256bit_shift:
; CHECK-MVE: @ %bb.0: @ %entry
; CHECK-MVE-NEXT: movs r1, #0
; CHECK-MVE-NEXT: str r1, [r0, #16]
; CHECK-MVE-NEXT: strd r1, r1, [r0, #8]
; CHECK-MVE-NEXT: strd r1, r1, [r0]
; CHECK-MVE-NEXT: ldrb r1, [r0, #23]
; CHECK-MVE-NEXT: lsls r1, r1, #24
; CHECK-MVE-NEXT: str r1, [r0, #20]
; CHECK-MVE-NEXT: bx lr
;
; CHECK-NON-MVE-LABEL: lsll_256bit_shift:
; CHECK-NON-MVE: @ %bb.0: @ %entry
; CHECK-NON-MVE-NEXT: movs r1, #0
; CHECK-NON-MVE-NEXT: str r1, [r0, #16]
; CHECK-NON-MVE-NEXT: str r1, [r0, #8]
; CHECK-NON-MVE-NEXT: str r1, [r0, #12]
; CHECK-NON-MVE-NEXT: str r1, [r0]
; CHECK-NON-MVE-NEXT: str r1, [r0, #4]
; CHECK-NON-MVE-NEXT: ldrb r1, [r0, #23]
; CHECK-NON-MVE-NEXT: lsls r1, r1, #24
; CHECK-NON-MVE-NEXT: str r1, [r0, #20]
; CHECK-NON-MVE-NEXT: bx lr
entry:
%0 = bitcast %struct.b* %x to i192*
%bf.load = load i192, i192* %0, align 8
%bf.clear4 = and i192 %bf.load, -24519928653854221733733552434404946937899825954937634816
store i192 %bf.clear4, i192* %0, align 8
ret void
}
|