forked from parquet-go/parquet-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page_bounds_amd64.s
551 lines (486 loc) · 10.5 KB
/
page_bounds_amd64.s
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
//go:build !purego
#include "textflag.h"
#define bswap128lo 0x08080A0B0C0D0E0F
#define bswap128hi 0x0001020304050607
DATA bswap128+0(SB)/8, $bswap128lo
DATA bswap128+8(SB)/8, $bswap128hi
DATA bswap128+16(SB)/8, $bswap128lo
DATA bswap128+24(SB)/8, $bswap128hi
DATA bswap128+32(SB)/8, $bswap128lo
DATA bswap128+40(SB)/8, $bswap128hi
DATA bswap128+48(SB)/8, $bswap128lo
DATA bswap128+56(SB)/8, $bswap128hi
GLOBL bswap128(SB), RODATA|NOPTR, $64
DATA indexes128+0(SB)/8, $0
DATA indexes128+8(SB)/8, $0
DATA indexes128+16(SB)/8, $1
DATA indexes128+24(SB)/8, $1
DATA indexes128+32(SB)/8, $2
DATA indexes128+40(SB)/8, $2
DATA indexes128+48(SB)/8, $3
DATA indexes128+56(SB)/8, $3
GLOBL indexes128(SB), RODATA|NOPTR, $64
DATA swap64+0(SB)/8, $4
DATA swap64+8(SB)/8, $5
DATA swap64+16(SB)/8, $6
DATA swap64+24(SB)/8, $7
DATA swap64+32(SB)/8, $2
DATA swap64+40(SB)/8, $3
DATA swap64+48(SB)/8, $0
DATA swap64+56(SB)/8, $1
GLOBL swap64(SB), RODATA|NOPTR, $64
DATA swap32+0(SB)/4, $8
DATA swap32+4(SB)/4, $9
DATA swap32+8(SB)/4, $10
DATA swap32+12(SB)/4, $11
DATA swap32+16(SB)/4, $12
DATA swap32+20(SB)/4, $13
DATA swap32+24(SB)/4, $14
DATA swap32+28(SB)/4, $15
DATA swap32+32(SB)/4, $4
DATA swap32+36(SB)/4, $5
DATA swap32+40(SB)/4, $6
DATA swap32+44(SB)/4, $7
DATA swap32+48(SB)/4, $2
DATA swap32+52(SB)/4, $3
DATA swap32+56(SB)/4, $0
DATA swap32+60(SB)/4, $1
GLOBL swap32(SB), RODATA|NOPTR, $64
// func combinedBoundsInt32(data []int32) (min, max int32)
TEXT ·combinedBoundsInt32(SB), NOSPLIT, $-32
MOVQ data_base+0(FP), AX
MOVQ data_len+8(FP), CX
XORQ R8, R8
XORQ R9, R9
CMPQ CX, $0
JE done
XORQ SI, SI
MOVLQZX (AX), R8 // min
MOVLQZX (AX), R9 // max
CMPB ·hasAVX512VL(SB), $0
JE loop
CMPQ CX, $32
JB loop
MOVQ CX, DI
SHRQ $5, DI
SHLQ $5, DI
VPBROADCASTD (AX), Z0
VPBROADCASTD (AX), Z3
loop32:
VMOVDQU32 (AX)(SI*4), Z1
VMOVDQU32 64(AX)(SI*4), Z2
VPMINSD Z1, Z0, Z0
VPMINSD Z2, Z0, Z0
VPMAXSD Z1, Z3, Z3
VPMAXSD Z2, Z3, Z3
ADDQ $32, SI
CMPQ SI, DI
JNE loop32
VMOVDQU32 swap32+0(SB), Z1
VMOVDQU32 swap32+0(SB), Z2
VPERMI2D Z0, Z0, Z1
VPERMI2D Z3, Z3, Z2
VPMINSD Y1, Y0, Y0
VPMAXSD Y2, Y3, Y3
VMOVDQU32 swap32+32(SB), Y1
VMOVDQU32 swap32+32(SB), Y2
VPERMI2D Y0, Y0, Y1
VPERMI2D Y3, Y3, Y2
VPMINSD X1, X0, X0
VPMAXSD X2, X3, X3
VMOVDQU32 swap32+48(SB), X1
VMOVDQU32 swap32+48(SB), X2
VPERMI2D X0, X0, X1
VPERMI2D X3, X3, X2
VPMINSD X1, X0, X0
VPMAXSD X2, X3, X3
VZEROUPPER
MOVQ X0, BX
MOVQ X3, DX
MOVL BX, R8
MOVL DX, R9
SHRQ $32, BX
SHRQ $32, DX
CMPL BX, R8
CMOVLLT BX, R8
CMPL DX, R9
CMOVLGT DX, R9
CMPQ SI, CX
JE done
loop:
MOVLQZX (AX)(SI*4), DX
CMPL DX, R8
CMOVLLT DX, R8
CMPL DX, R9
CMOVLGT DX, R9
INCQ SI
CMPQ SI, CX
JNE loop
done:
MOVL R8, min+24(FP)
MOVL R9, max+28(FP)
RET
// func combinedBoundsInt64(data []int64) (min, max int64)
TEXT ·combinedBoundsInt64(SB), NOSPLIT, $-40
MOVQ data_base+0(FP), AX
MOVQ data_len+8(FP), CX
XORQ R8, R8
XORQ R9, R9
CMPQ CX, $0
JE done
XORQ SI, SI
MOVQ (AX), R8 // min
MOVQ (AX), R9 // max
CMPB ·hasAVX512VL(SB), $0
JE loop
CMPQ CX, $16
JB loop
MOVQ CX, DI
SHRQ $4, DI
SHLQ $4, DI
VPBROADCASTQ (AX), Z0
VPBROADCASTQ (AX), Z3
loop16:
VMOVDQU64 (AX)(SI*8), Z1
VMOVDQU64 64(AX)(SI*8), Z2
VPMINSQ Z1, Z0, Z0
VPMINSQ Z2, Z0, Z0
VPMAXSQ Z1, Z3, Z3
VPMAXSQ Z2, Z3, Z3
ADDQ $16, SI
CMPQ SI, DI
JNE loop16
VMOVDQU32 swap32+0(SB), Z1
VMOVDQU32 swap32+0(SB), Z2
VPERMI2D Z0, Z0, Z1
VPERMI2D Z3, Z3, Z2
VPMINSQ Y1, Y0, Y0
VPMAXSQ Y2, Y3, Y3
VMOVDQU32 swap32+32(SB), Y1
VMOVDQU32 swap32+32(SB), Y2
VPERMI2D Y0, Y0, Y1
VPERMI2D Y3, Y3, Y2
VPMINSQ X1, X0, X0
VPMAXSQ X2, X3, X3
VMOVDQU32 swap32+48(SB), X1
VMOVDQU32 swap32+48(SB), X2
VPERMI2D X0, X0, X1
VPERMI2D X3, X3, X2
VPMINSQ X1, X0, X0
VPMAXSQ X2, X3, X3
VZEROUPPER
MOVQ X0, R8
MOVQ X3, R9
CMPQ SI, CX
JE done
loop:
MOVQ (AX)(SI*8), DX
CMPQ DX, R8
CMOVQLT DX, R8
CMPQ DX, R9
CMOVQGT DX, R9
INCQ SI
CMPQ SI, CX
JNE loop
done:
MOVQ R8, min+24(FP)
MOVQ R9, max+32(FP)
RET
// func combinedBoundsUint32(data []uint32) (min, max uint32)
TEXT ·combinedBoundsUint32(SB), NOSPLIT, $-32
MOVQ data_base+0(FP), AX
MOVQ data_len+8(FP), CX
XORQ R8, R8
XORQ R9, R9
CMPQ CX, $0
JE done
XORQ SI, SI
MOVLQZX (AX), R8 // min
MOVLQZX (AX), R9 // max
CMPB ·hasAVX512VL(SB), $0
JE loop
CMPQ CX, $32
JB loop
MOVQ CX, DI
SHRQ $5, DI
SHLQ $5, DI
VPBROADCASTD (AX), Z0
VPBROADCASTD (AX), Z3
loop32:
VMOVDQU32 (AX)(SI*4), Z1
VMOVDQU32 64(AX)(SI*4), Z2
VPMINUD Z1, Z0, Z0
VPMINUD Z2, Z0, Z0
VPMAXUD Z1, Z3, Z3
VPMAXUD Z2, Z3, Z3
ADDQ $32, SI
CMPQ SI, DI
JNE loop32
VMOVDQU32 swap32+0(SB), Z1
VMOVDQU32 swap32+0(SB), Z2
VPERMI2D Z0, Z0, Z1
VPERMI2D Z3, Z3, Z2
VPMINUD Y1, Y0, Y0
VPMAXUD Y2, Y3, Y3
VMOVDQU32 swap32+32(SB), Y1
VMOVDQU32 swap32+32(SB), Y2
VPERMI2D Y0, Y0, Y1
VPERMI2D Y3, Y3, Y2
VPMINUD X1, X0, X0
VPMAXUD X2, X3, X3
VMOVDQU32 swap32+48(SB), X1
VMOVDQU32 swap32+48(SB), X2
VPERMI2D X0, X0, X1
VPERMI2D X3, X3, X2
VPMINUD X1, X0, X0
VPMAXUD X2, X3, X3
VZEROUPPER
MOVQ X0, BX
MOVQ X3, DX
MOVL BX, R8
MOVL DX, R9
SHRQ $32, BX
SHRQ $32, DX
CMPL BX, R8
CMOVLCS BX, R8
CMPL DX, R9
CMOVLHI DX, R9
CMPQ SI, CX
JE done
loop:
MOVLQZX (AX)(SI*4), DX
CMPL DX, R8
CMOVLCS DX, R8
CMPL DX, R9
CMOVLHI DX, R9
INCQ SI
CMPQ SI, CX
JNE loop
done:
MOVL R8, min+24(FP)
MOVL R9, max+28(FP)
RET
// func combinedBoundsUint64(data []uint64) (min, max uint64)
TEXT ·combinedBoundsUint64(SB), NOSPLIT, $-40
MOVQ data_base+0(FP), AX
MOVQ data_len+8(FP), CX
XORQ R8, R8
XORQ R9, R9
CMPQ CX, $0
JE done
XORQ SI, SI
MOVQ (AX), R8 // min
MOVQ (AX), R9 // max
CMPB ·hasAVX512VL(SB), $0
JE loop
CMPQ CX, $16
JB loop
MOVQ CX, DI
SHRQ $4, DI
SHLQ $4, DI
VPBROADCASTQ (AX), Z0
VPBROADCASTQ (AX), Z3
loop16:
VMOVDQU64 (AX)(SI*8), Z1
VMOVDQU64 64(AX)(SI*8), Z2
VPMINUQ Z1, Z0, Z0
VPMINUQ Z2, Z0, Z0
VPMAXUQ Z1, Z3, Z3
VPMAXUQ Z2, Z3, Z3
ADDQ $16, SI
CMPQ SI, DI
JNE loop16
VMOVDQU32 swap32+0(SB), Z1
VMOVDQU32 swap32+0(SB), Z2
VPERMI2D Z0, Z0, Z1
VPERMI2D Z3, Z3, Z2
VPMINUQ Y1, Y0, Y0
VPMAXUQ Y2, Y3, Y3
VMOVDQU32 swap32+32(SB), Y1
VMOVDQU32 swap32+32(SB), Y2
VPERMI2D Y0, Y0, Y1
VPERMI2D Y3, Y3, Y2
VPMINUQ X1, X0, X0
VPMAXUQ X2, X3, X3
VMOVDQU32 swap32+48(SB), X1
VMOVDQU32 swap32+48(SB), X2
VPERMI2D X0, X0, X1
VPERMI2D X3, X3, X2
VPMINUQ X1, X0, X0
VPMAXUQ X2, X3, X3
VZEROUPPER
MOVQ X0, R8
MOVQ X3, R9
CMPQ SI, CX
JE done
loop:
MOVQ (AX)(SI*8), DX
CMPQ DX, R8
CMOVQCS DX, R8
CMPQ DX, R9
CMOVQHI DX, R9
INCQ SI
CMPQ SI, CX
JNE loop
done:
MOVQ R8, min+24(FP)
MOVQ R9, max+32(FP)
RET
// func combinedBoundsFloat32(data []float32) (min, max float32)
TEXT ·combinedBoundsFloat32(SB), NOSPLIT, $-32
MOVQ data_base+0(FP), AX
MOVQ data_len+8(FP), CX
XORQ R8, R8
XORQ R9, R9
CMPQ CX, $0
JE done
XORPS X0, X0
XORPS X1, X1
XORQ SI, SI
MOVLQZX (AX), R8 // min
MOVLQZX (AX), R9 // max
MOVQ R8, X0
MOVQ R9, X1
CMPB ·hasAVX512VL(SB), $0
JE loop
CMPQ CX, $32
JB loop
MOVQ CX, DI
SHRQ $5, DI
SHLQ $5, DI
VPBROADCASTD (AX), Z0
VPBROADCASTD (AX), Z3
loop32:
VMOVDQU32 (AX)(SI*4), Z1
VMOVDQU32 64(AX)(SI*4), Z2
VMINPS Z1, Z0, Z0
VMINPS Z2, Z0, Z0
VMAXPS Z1, Z3, Z3
VMAXPS Z2, Z3, Z3
ADDQ $32, SI
CMPQ SI, DI
JNE loop32
VMOVDQU32 swap32+0(SB), Z1
VMOVDQU32 swap32+0(SB), Z2
VPERMI2D Z0, Z0, Z1
VPERMI2D Z3, Z3, Z2
VMINPS Y1, Y0, Y0
VMAXPS Y2, Y3, Y3
VMOVDQU32 swap32+32(SB), Y1
VMOVDQU32 swap32+32(SB), Y2
VPERMI2D Y0, Y0, Y1
VPERMI2D Y3, Y3, Y2
VMINPS X1, X0, X0
VMAXPS X2, X3, X3
VMOVDQU32 swap32+48(SB), X1
VMOVDQU32 swap32+48(SB), X2
VPERMI2D X0, X0, X1
VPERMI2D X3, X3, X2
VMINPS X1, X0, X0
VMAXPS X2, X3, X3
VZEROUPPER
MOVAPS X0, X1
MOVAPS X3, X2
PSRLQ $32, X1
MOVQ X0, R8
MOVQ X1, R10
UCOMISS X0, X1
CMOVLCS R10, R8
PSRLQ $32, X2
MOVQ X3, R9
MOVQ X2, R11
UCOMISS X3, X2
CMOVLHI R11, R9
CMPQ SI, CX
JE done
MOVQ R8, X0
MOVQ R9, X1
loop:
MOVLQZX (AX)(SI*4), DX
MOVQ DX, X2
UCOMISS X0, X2
CMOVLCS DX, R8
UCOMISS X1, X2
CMOVLHI DX, R9
MOVQ R8, X0
MOVQ R9, X1
INCQ SI
CMPQ SI, CX
JNE loop
done:
MOVL R8, min+24(FP)
MOVL R9, max+28(FP)
RET
// func combinedBoundsFloat64(data []float64) (min, max float64)
TEXT ·combinedBoundsFloat64(SB), NOSPLIT, $-40
MOVQ data_base+0(FP), AX
MOVQ data_len+8(FP), CX
XORQ R8, R8
XORQ R9, R9
CMPQ CX, $0
JE done
XORPD X0, X0
XORPD X1, X1
XORQ SI, SI
MOVQ (AX), R8 // min
MOVQ (AX), R9 // max
MOVQ R8, X0
MOVQ R9, X1
CMPB ·hasAVX512VL(SB), $0
JE loop
CMPQ CX, $16
JB loop
MOVQ CX, DI
SHRQ $4, DI
SHLQ $4, DI
VPBROADCASTQ (AX), Z0
VPBROADCASTQ (AX), Z3
loop16:
VMOVDQU64 (AX)(SI*8), Z1
VMOVDQU64 64(AX)(SI*8), Z2
VMINPD Z1, Z0, Z0
VMINPD Z2, Z0, Z0
VMAXPD Z1, Z3, Z3
VMAXPD Z2, Z3, Z3
ADDQ $16, SI
CMPQ SI, DI
JNE loop16
VMOVDQU64 swap32+0(SB), Z1
VMOVDQU64 swap32+0(SB), Z2
VPERMI2D Z0, Z0, Z1
VPERMI2D Z3, Z3, Z2
VMINPD Y1, Y0, Y0
VMAXPD Y2, Y3, Y3
VMOVDQU64 swap32+32(SB), Y1
VMOVDQU64 swap32+32(SB), Y2
VPERMI2D Y0, Y0, Y1
VPERMI2D Y3, Y3, Y2
VMINPD X1, X0, X0
VMAXPD X2, X3, X3
VMOVDQU64 swap32+48(SB), X1
VMOVDQU64 swap32+48(SB), X2
VPERMI2D X0, X0, X1
VPERMI2D X3, X3, X2
VMINPD X1, X0, X0
VMAXPD X2, X3, X1
VZEROUPPER
MOVQ X0, R8
MOVQ X1, R9
CMPQ SI, CX
JE done
loop:
MOVQ (AX)(SI*8), DX
MOVQ DX, X2
UCOMISD X0, X2
CMOVQCS DX, R8
UCOMISD X1, X2
CMOVQHI DX, R9
MOVQ R8, X0
MOVQ R9, X1
INCQ SI
CMPQ SI, CX
JNE loop
done:
MOVQ R8, min+24(FP)
MOVQ R9, max+32(FP)
RET