aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/AArch64/sitofp-to-tbl.ll
blob: 3e708b0678fbcd750a8d9b48550c53a199fba703 (plain)
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
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -verify-machineinstrs < %s | FileCheck %s

target triple = "aarch64-linux"

; CHECK-LABEL: .LCPI0_0:
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    4
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    5
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    6
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    7
; CHECK-NEXT:  .LCPI0_1:
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    0
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    1
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    2
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    255
; CHECK-NEXT:  .byte    3

define void @sitofp_v8i8_to_v8f32(ptr %src, ptr %dst) {
; CHECK-LABEL: sitofp_v8i8_to_v8f32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    adrp x8, .LCPI0_0
; CHECK-NEXT:    adrp x9, .LCPI0_1
; CHECK-NEXT:    ldr q0, [x8, :lo12:.LCPI0_0]
; CHECK-NEXT:    ldr q1, [x9, :lo12:.LCPI0_1]
; CHECK-NEXT:    mov x8, xzr
; CHECK-NEXT:  .LBB0_1: // %loop
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    ldr d2, [x0, x8, lsl #3]
; CHECK-NEXT:    add x9, x1, x8, lsl #5
; CHECK-NEXT:    add x8, x8, #1
; CHECK-NEXT:    cmp x8, #1000
; CHECK-NEXT:    tbl v3.16b, { v2.16b }, v0.16b
; CHECK-NEXT:    tbl v2.16b, { v2.16b }, v1.16b
; CHECK-NEXT:    scvtf v3.4s, v3.4s, #24
; CHECK-NEXT:    scvtf v2.4s, v2.4s, #24
; CHECK-NEXT:    stp q2, q3, [x9]
; CHECK-NEXT:    b.eq .LBB0_1
; CHECK-NEXT:  // %bb.2: // %exit
; CHECK-NEXT:    ret
entry:
  br label %loop

loop:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %gep.src = getelementptr inbounds <8 x i8>, ptr %src, i64 %iv
  %l = load <8 x i8>, ptr %gep.src
  %conv = sitofp <8 x i8> %l to <8 x float>
  %gep.dst = getelementptr inbounds <8 x float>, ptr %dst, i64 %iv
  store <8 x float> %conv, ptr %gep.dst
  %iv.next = add i64 %iv, 1
  %ec = icmp eq i64 %iv.next, 1000
  br i1 %ec, label %loop, label %exit

exit:
  ret void
}

; CHECK-LABEL: .LCPI1_0:
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    12
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    13
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    14
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    15
; CHECK-NEXT: .LCPI1_1:
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    8
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    9
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    10
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    11
; CHECK-NEXT: .LCPI1_2:
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    4
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    5
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    6
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    7
; CHECK-NEXT: .LCPI1_3:
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    0
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    1
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    2
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    255
; CHECK-NEXT: .byte    3

define void @sitofp_v16i8_to_v16f32(ptr %src, ptr %dst) {
; CHECK-LABEL: sitofp_v16i8_to_v16f32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    adrp x8, .LCPI1_0
; CHECK-NEXT:    adrp x9, .LCPI1_1
; CHECK-NEXT:    adrp x10, .LCPI1_2
; CHECK-NEXT:    ldr q0, [x8, :lo12:.LCPI1_0]
; CHECK-NEXT:    adrp x8, .LCPI1_3
; CHECK-NEXT:    ldr q1, [x9, :lo12:.LCPI1_1]
; CHECK-NEXT:    ldr q2, [x10, :lo12:.LCPI1_2]
; CHECK-NEXT:    ldr q3, [x8, :lo12:.LCPI1_3]
; CHECK-NEXT:    mov x8, xzr
; CHECK-NEXT:  .LBB1_1: // %loop
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    ldr q4, [x0, x8, lsl #4]
; CHECK-NEXT:    add x9, x1, x8, lsl #6
; CHECK-NEXT:    add x8, x8, #1
; CHECK-NEXT:    cmp x8, #1000
; CHECK-NEXT:    tbl v5.16b, { v4.16b }, v0.16b
; CHECK-NEXT:    tbl v6.16b, { v4.16b }, v1.16b
; CHECK-NEXT:    tbl v7.16b, { v4.16b }, v2.16b
; CHECK-NEXT:    tbl v4.16b, { v4.16b }, v3.16b
; CHECK-NEXT:    scvtf v5.4s, v5.4s, #24
; CHECK-NEXT:    scvtf v6.4s, v6.4s, #24
; CHECK-NEXT:    scvtf v7.4s, v7.4s, #24
; CHECK-NEXT:    scvtf v4.4s, v4.4s, #24
; CHECK-NEXT:    stp q6, q5, [x9, #32]
; CHECK-NEXT:    stp q4, q7, [x9]
; CHECK-NEXT:    b.eq .LBB1_1
; CHECK-NEXT:  // %bb.2: // %exit
; CHECK-NEXT:    ret
entry:
  br label %loop

loop:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %gep.src = getelementptr inbounds <16 x i8>, ptr %src, i64 %iv
  %l = load <16 x i8>, ptr %gep.src
  %conv = sitofp <16 x i8> %l to <16 x float>
  %gep.dst = getelementptr inbounds <16 x float>, ptr %dst, i64 %iv
  store <16 x float> %conv, ptr %gep.dst
  %iv.next = add i64 %iv, 1
  %ec = icmp eq i64 %iv.next, 1000
  br i1 %ec, label %loop, label %exit

exit:
  ret void
}


; Negative tests, currently we don't convert to f16/bf16 via `tbl`.
define void @sitofp_v8i8_to_v8f16(ptr %src, ptr %dst) {
; CHECK-LABEL: sitofp_v8i8_to_v8f16:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov x8, xzr
; CHECK-NEXT:  .LBB2_1: // %loop
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    ldr d0, [x0, x8, lsl #3]
; CHECK-NEXT:    sshll v0.8h, v0.8b, #0
; CHECK-NEXT:    sshll v1.4s, v0.4h, #0
; CHECK-NEXT:    sshll2 v0.4s, v0.8h, #0
; CHECK-NEXT:    scvtf v1.4s, v1.4s
; CHECK-NEXT:    scvtf v0.4s, v0.4s
; CHECK-NEXT:    fcvtn v1.4h, v1.4s
; CHECK-NEXT:    fcvtn2 v1.8h, v0.4s
; CHECK-NEXT:    str q1, [x1, x8, lsl #4]
; CHECK-NEXT:    add x8, x8, #1
; CHECK-NEXT:    cmp x8, #1000
; CHECK-NEXT:    b.eq .LBB2_1
; CHECK-NEXT:  // %bb.2: // %exit
; CHECK-NEXT:    ret
entry:
  br label %loop

loop:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %gep.src = getelementptr inbounds <8 x i8>, ptr %src, i64 %iv
  %l = load <8 x i8>, ptr %gep.src
  %conv = sitofp <8 x i8> %l to <8 x half>
  %gep.dst = getelementptr inbounds <8 x half>, ptr %dst, i64 %iv
  store <8 x half> %conv, ptr %gep.dst
  %iv.next = add i64 %iv, 1
  %ec = icmp eq i64 %iv.next, 1000
  br i1 %ec, label %loop, label %exit

exit:
  ret void
}


; Negative test, conversion to double with the help of `tbl` not implemented (TODO)
define void @sitofp_v2i8_to_v2f64(ptr %src, ptr %dst) {
; CHECK-LABEL: sitofp_v2i8_to_v2f64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov x8, xzr
; CHECK-NEXT:  .LBB3_1: // %loop
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    add x9, x0, x8, lsl #1
; CHECK-NEXT:    ldrsb w10, [x9]
; CHECK-NEXT:    ldrsb w9, [x9, #1]
; CHECK-NEXT:    fmov s0, w10
; CHECK-NEXT:    mov v0.s[1], w9
; CHECK-NEXT:    sshll v0.2d, v0.2s, #0
; CHECK-NEXT:    scvtf v0.2d, v0.2d
; CHECK-NEXT:    str q0, [x1, x8, lsl #4]
; CHECK-NEXT:    add x8, x8, #1
; CHECK-NEXT:    cmp x8, #1000
; CHECK-NEXT:    b.eq .LBB3_1
; CHECK-NEXT:  // %bb.2: // %exit
; CHECK-NEXT:    ret
entry:
  br label %loop

loop:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %gep.src = getelementptr inbounds <2 x i8>, ptr %src, i64 %iv
  %l = load <2 x i8>, ptr %gep.src
  %conv = sitofp <2 x i8> %l to <2 x double>
  %gep.dst = getelementptr inbounds <2 x double>, ptr %dst, i64 %iv
  store <2 x double> %conv, ptr %gep.dst
  %iv.next = add i64 %iv, 1
  %ec = icmp eq i64 %iv.next, 1000
  br i1 %ec, label %loop, label %exit

exit:
  ret void
}