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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
|
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AOM_AOM_DSP_SIMD_V64_INTRINSICS_ARM_H_
#define AOM_AOM_DSP_SIMD_V64_INTRINSICS_ARM_H_
#include <arm_neon.h>
#include "aom_dsp/simd/v64_intrinsics_arm.h"
#include "aom_ports/arm.h"
#ifdef AOM_INCOMPATIBLE_GCC
#error Incompatible gcc
#endif
typedef int64x1_t v64;
SIMD_INLINE uint32_t v64_low_u32(v64 a) {
return vget_lane_u32(vreinterpret_u32_s64(a), 0);
}
SIMD_INLINE uint32_t v64_high_u32(v64 a) {
return vget_lane_u32(vreinterpret_u32_s64(a), 1);
}
SIMD_INLINE int32_t v64_low_s32(v64 a) {
return vget_lane_s32(vreinterpret_s32_s64(a), 0);
}
SIMD_INLINE int32_t v64_high_s32(v64 a) {
return vget_lane_s32(vreinterpret_s32_s64(a), 1);
}
SIMD_INLINE v64 v64_from_16(uint16_t a, uint16_t b, uint16_t c, uint16_t d) {
return vcreate_s64((uint64_t)a << 48 | (uint64_t)b << 32 | (uint64_t)c << 16 |
d);
}
SIMD_INLINE v64 v64_from_32(uint32_t x, uint32_t y) {
return vcreate_s64((uint64_t)x << 32 | y);
}
SIMD_INLINE v64 v64_from_64(uint64_t x) { return vcreate_s64(x); }
SIMD_INLINE uint64_t v64_u64(v64 x) { return (uint64_t)x; }
SIMD_INLINE uint32_t u32_load_aligned(const void *p) {
return *((uint32_t *)p);
}
SIMD_INLINE uint32_t u32_load_unaligned(const void *p) {
return vget_lane_u32(vreinterpret_u32_u8(vld1_u8((const uint8_t *)p)), 0);
}
SIMD_INLINE void u32_store_aligned(void *p, uint32_t a) {
*((uint32_t *)p) = a;
}
SIMD_INLINE void u32_store_unaligned(void *p, uint32_t a) {
#if defined(__clang__)
vst1_lane_u32((uint32_t *)p, vreinterpret_u32_s64((uint64x1_t)(uint64_t)a),
0);
#elif defined(__CC_ARM)
*(__packed uint32_t *)p) = a;
#elif defined(__GNUC__)
struct Unaligned32Struct {
uint32_t value;
uint8_t dummy; // To make the size non-power-of-two.
} __attribute__((__packed__));
((struct Unaligned32Struct *)p)->value = a;
#else
vst1_lane_u32((uint32_t *)p, vreinterpret_u32_s64((uint64x1_t)(uint64_t)a),
0);
#endif
}
SIMD_INLINE v64 v64_load_aligned(const void *p) {
return vreinterpret_s64_u8(vld1_u8((const uint8_t *)p));
}
SIMD_INLINE v64 v64_load_unaligned(const void *p) {
return v64_load_aligned(p);
}
SIMD_INLINE void v64_store_aligned(void *p, v64 r) {
vst1_u8((uint8_t *)p, vreinterpret_u8_s64(r));
}
SIMD_INLINE void v64_store_unaligned(void *p, v64 r) {
vst1_u8((uint8_t *)p, vreinterpret_u8_s64(r));
}
// The following function requires an immediate.
// Some compilers will check this if it's optimising, others wont.
SIMD_INLINE v64 v64_align(v64 a, v64 b, unsigned int c) {
#if defined(__OPTIMIZE__) && __OPTIMIZE__ && !defined(__clang__)
return c ? vreinterpret_s64_s8(
vext_s8(vreinterpret_s8_s64(b), vreinterpret_s8_s64(a), c))
: b;
#else
return c ? v64_from_64(((uint64_t)b >> c * 8) | ((uint64_t)a << (8 - c) * 8))
: b;
#endif
}
SIMD_INLINE v64 v64_zero(void) { return vreinterpret_s64_u8(vdup_n_u8(0)); }
SIMD_INLINE v64 v64_dup_8(uint8_t x) {
return vreinterpret_s64_u8(vdup_n_u8(x));
}
SIMD_INLINE v64 v64_dup_16(uint16_t x) {
return vreinterpret_s64_u16(vdup_n_u16(x));
}
SIMD_INLINE v64 v64_dup_32(uint32_t x) {
return vreinterpret_s64_u32(vdup_n_u32(x));
}
SIMD_INLINE int64_t v64_dotp_su8(v64 x, v64 y) {
int16x8_t t =
vmulq_s16(vmovl_s8(vreinterpret_s8_s64(x)),
vreinterpretq_s16_u16(vmovl_u8(vreinterpret_u8_s64(y))));
#if defined(__aarch64__)
return vaddlvq_s16(t);
#else
int64x2_t r = vpaddlq_s32(vpaddlq_s16(t));
return (int64_t)vadd_s64(vget_high_s64(r), vget_low_s64(r));
#endif
}
SIMD_INLINE int64_t v64_dotp_s16(v64 x, v64 y) {
#if defined(__aarch64__)
return vaddlvq_s32(
vmull_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
#else
int64x2_t r =
vpaddlq_s32(vmull_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
return (int64_t)(vget_high_s64(r) + vget_low_s64(r));
#endif
}
SIMD_INLINE uint64_t v64_hadd_u8(v64 x) {
#if defined(__aarch64__)
return vaddlv_u8(vreinterpret_u8_s64(x));
#else
return (uint64_t)vpaddl_u32(vpaddl_u16(vpaddl_u8(vreinterpret_u8_s64(x))));
#endif
}
SIMD_INLINE int64_t v64_hadd_s16(v64 a) {
return (int64_t)vpaddl_s32(vpaddl_s16(vreinterpret_s16_s64(a)));
}
typedef uint16x8_t sad64_internal;
SIMD_INLINE sad64_internal v64_sad_u8_init(void) { return vdupq_n_u16(0); }
// Implementation dependent return value. Result must be finalised with
// v64_sad_u8_sum().
SIMD_INLINE sad64_internal v64_sad_u8(sad64_internal s, v64 a, v64 b) {
return vabal_u8(s, vreinterpret_u8_s64(a), vreinterpret_u8_s64(b));
}
SIMD_INLINE uint32_t v64_sad_u8_sum(sad64_internal s) {
#if defined(__aarch64__)
return vaddlvq_u16(s);
#else
uint64x2_t r = vpaddlq_u32(vpaddlq_u16(s));
return (uint32_t)(uint64_t)(vget_high_u64(r) + vget_low_u64(r));
#endif
}
typedef uint32x4_t ssd64_internal;
SIMD_INLINE ssd64_internal v64_ssd_u8_init(void) { return vdupq_n_u32(0); }
// Implementation dependent return value. Result must be finalised with
// v64_ssd_u8_sum().
SIMD_INLINE ssd64_internal v64_ssd_u8(ssd64_internal s, v64 a, v64 b) {
uint8x8_t t = vabd_u8(vreinterpret_u8_s64(a), vreinterpret_u8_s64(b));
return vaddq_u32(s, vpaddlq_u16(vmull_u8(t, t)));
}
SIMD_INLINE uint32_t v64_ssd_u8_sum(ssd64_internal s) {
#if defined(__aarch64__)
return vaddvq_u32(s);
#else
uint64x2_t t = vpaddlq_u32(s);
return vget_lane_u32(
vreinterpret_u32_u64(vadd_u64(vget_high_u64(t), vget_low_u64(t))), 0);
#endif
}
SIMD_INLINE v64 v64_or(v64 x, v64 y) { return vorr_s64(x, y); }
SIMD_INLINE v64 v64_xor(v64 x, v64 y) { return veor_s64(x, y); }
SIMD_INLINE v64 v64_and(v64 x, v64 y) { return vand_s64(x, y); }
SIMD_INLINE v64 v64_andn(v64 x, v64 y) { return vbic_s64(x, y); }
SIMD_INLINE v64 v64_add_8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vadd_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_sadd_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vqadd_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_sadd_s8(v64 x, v64 y) {
return vreinterpret_s64_s8(
vqadd_s8(vreinterpret_s8_s64(x), vreinterpret_s8_s64(y)));
}
SIMD_INLINE v64 v64_add_16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vadd_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_sadd_s16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vqadd_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_add_32(v64 x, v64 y) {
return vreinterpret_s64_u32(
vadd_u32(vreinterpret_u32_s64(x), vreinterpret_u32_s64(y)));
}
SIMD_INLINE v64 v64_sub_8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vsub_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_sub_16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vsub_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_ssub_s16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vqsub_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_ssub_u16(v64 x, v64 y) {
return vreinterpret_s64_u16(
vqsub_u16(vreinterpret_u16_s64(x), vreinterpret_u16_s64(y)));
}
SIMD_INLINE v64 v64_ssub_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vqsub_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_ssub_s8(v64 x, v64 y) {
return vreinterpret_s64_s8(
vqsub_s8(vreinterpret_s8_s64(x), vreinterpret_s8_s64(y)));
}
SIMD_INLINE v64 v64_sub_32(v64 x, v64 y) {
return vreinterpret_s64_s32(
vsub_s32(vreinterpret_s32_s64(x), vreinterpret_s32_s64(y)));
}
SIMD_INLINE v64 v64_abs_s16(v64 x) {
return vreinterpret_s64_s16(vabs_s16(vreinterpret_s16_s64(x)));
}
SIMD_INLINE v64 v64_abs_s8(v64 x) {
return vreinterpret_s64_s8(vabs_s8(vreinterpret_s8_s64(x)));
}
SIMD_INLINE v64 v64_mullo_s16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vmul_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_mulhi_s16(v64 x, v64 y) {
#if defined(__aarch64__)
int16x8_t t = vreinterpretq_s16_s32(
vmull_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
return vget_low_s64(vreinterpretq_s64_s16(vuzp2q_s16(t, t)));
#else
return vreinterpret_s64_s16(vmovn_s32(vshrq_n_s32(
vmull_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)), 16)));
#endif
}
SIMD_INLINE v64 v64_mullo_s32(v64 x, v64 y) {
return vreinterpret_s64_s32(
vmul_s32(vreinterpret_s32_s64(x), vreinterpret_s32_s64(y)));
}
SIMD_INLINE v64 v64_madd_s16(v64 x, v64 y) {
int32x4_t t = vmull_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y));
return vreinterpret_s64_s32(
vpadd_s32(vreinterpret_s32_s64(vget_low_s64(vreinterpretq_s64_s32(t))),
vreinterpret_s32_s64(vget_high_s64(vreinterpretq_s64_s32(t)))));
}
SIMD_INLINE v64 v64_madd_us8(v64 x, v64 y) {
int16x8_t t =
vmulq_s16(vreinterpretq_s16_u16(vmovl_u8(vreinterpret_u8_s64(x))),
vmovl_s8(vreinterpret_s8_s64(y)));
return vreinterpret_s64_s16(vqmovn_s32(vpaddlq_s16(t)));
}
SIMD_INLINE v64 v64_avg_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vrhadd_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_rdavg_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vhadd_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_rdavg_u16(v64 x, v64 y) {
return vreinterpret_s64_u16(
vhadd_u16(vreinterpret_u16_s64(x), vreinterpret_u16_s64(y)));
}
SIMD_INLINE v64 v64_avg_u16(v64 x, v64 y) {
return vreinterpret_s64_u16(
vrhadd_u16(vreinterpret_u16_s64(x), vreinterpret_u16_s64(y)));
}
SIMD_INLINE v64 v64_max_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vmax_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_min_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vmin_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_max_s8(v64 x, v64 y) {
return vreinterpret_s64_s8(
vmax_s8(vreinterpret_s8_s64(x), vreinterpret_s8_s64(y)));
}
SIMD_INLINE v64 v64_min_s8(v64 x, v64 y) {
return vreinterpret_s64_s8(
vmin_s8(vreinterpret_s8_s64(x), vreinterpret_s8_s64(y)));
}
SIMD_INLINE v64 v64_max_s16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vmax_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_min_s16(v64 x, v64 y) {
return vreinterpret_s64_s16(
vmin_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_ziplo_8(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u8(
vzip1_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x)));
#else
uint8x8x2_t r = vzip_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x));
return vreinterpret_s64_u8(r.val[0]);
#endif
}
SIMD_INLINE v64 v64_ziphi_8(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u8(
vzip2_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x)));
#else
uint8x8x2_t r = vzip_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x));
return vreinterpret_s64_u8(r.val[1]);
#endif
}
SIMD_INLINE v64 v64_ziplo_16(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u16(
vzip1_u16(vreinterpret_u16_s64(y), vreinterpret_u16_s64(x)));
#else
int16x4x2_t r = vzip_s16(vreinterpret_s16_s64(y), vreinterpret_s16_s64(x));
return vreinterpret_s64_s16(r.val[0]);
#endif
}
SIMD_INLINE v64 v64_ziphi_16(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u16(
vzip2_u16(vreinterpret_u16_s64(y), vreinterpret_u16_s64(x)));
#else
int16x4x2_t r = vzip_s16(vreinterpret_s16_s64(y), vreinterpret_s16_s64(x));
return vreinterpret_s64_s16(r.val[1]);
#endif
}
SIMD_INLINE v64 v64_ziplo_32(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u32(
vzip1_u32(vreinterpret_u32_s64(y), vreinterpret_u32_s64(x)));
#else
int32x2x2_t r = vzip_s32(vreinterpret_s32_s64(y), vreinterpret_s32_s64(x));
return vreinterpret_s64_s32(r.val[0]);
#endif
}
SIMD_INLINE v64 v64_ziphi_32(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u32(
vzip2_u32(vreinterpret_u32_s64(y), vreinterpret_u32_s64(x)));
#else
int32x2x2_t r = vzip_s32(vreinterpret_s32_s64(y), vreinterpret_s32_s64(x));
return vreinterpret_s64_s32(r.val[1]);
#endif
}
SIMD_INLINE v64 v64_unpacklo_u8_s16(v64 a) {
return vreinterpret_s64_u16(vget_low_u16(vmovl_u8(vreinterpret_u8_s64(a))));
}
SIMD_INLINE v64 v64_unpackhi_u8_s16(v64 a) {
return vreinterpret_s64_u16(vget_high_u16(vmovl_u8(vreinterpret_u8_s64(a))));
}
SIMD_INLINE v64 v64_unpacklo_s8_s16(v64 a) {
return vreinterpret_s64_s16(vget_low_s16(vmovl_s8(vreinterpret_s8_s64(a))));
}
SIMD_INLINE v64 v64_unpackhi_s8_s16(v64 a) {
return vreinterpret_s64_s16(vget_high_s16(vmovl_s8(vreinterpret_s8_s64(a))));
}
SIMD_INLINE v64 v64_pack_s32_s16(v64 x, v64 y) {
return vreinterpret_s64_s16(vqmovn_s32(
vcombine_s32(vreinterpret_s32_s64(y), vreinterpret_s32_s64(x))));
}
SIMD_INLINE v64 v64_pack_s32_u16(v64 x, v64 y) {
return vreinterpret_s64_u16(vqmovun_s32(
vcombine_s32(vreinterpret_s32_s64(y), vreinterpret_s32_s64(x))));
}
SIMD_INLINE v64 v64_pack_s16_u8(v64 x, v64 y) {
return vreinterpret_s64_u8(vqmovun_s16(vreinterpretq_s16_s32(
vcombine_s32(vreinterpret_s32_s64(y), vreinterpret_s32_s64(x)))));
}
SIMD_INLINE v64 v64_pack_s16_s8(v64 x, v64 y) {
return vreinterpret_s64_s8(vqmovn_s16(vreinterpretq_s16_s32(
vcombine_s32(vreinterpret_s32_s64(y), vreinterpret_s32_s64(x)))));
}
SIMD_INLINE v64 v64_unziplo_8(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u8(
vuzp1_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x)));
#else
uint8x8x2_t r = vuzp_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x));
return vreinterpret_s64_u8(r.val[0]);
#endif
}
SIMD_INLINE v64 v64_unziphi_8(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u8(
vuzp2_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x)));
#else
uint8x8x2_t r = vuzp_u8(vreinterpret_u8_s64(y), vreinterpret_u8_s64(x));
return vreinterpret_s64_u8(r.val[1]);
#endif
}
SIMD_INLINE v64 v64_unziplo_16(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u16(
vuzp1_u16(vreinterpret_u16_s64(y), vreinterpret_u16_s64(x)));
#else
uint16x4x2_t r = vuzp_u16(vreinterpret_u16_s64(y), vreinterpret_u16_s64(x));
return vreinterpret_s64_u16(r.val[0]);
#endif
}
SIMD_INLINE v64 v64_unziphi_16(v64 x, v64 y) {
#if defined(__aarch64__)
return vreinterpret_s64_u16(
vuzp2_u16(vreinterpret_u16_s64(y), vreinterpret_u16_s64(x)));
#else
uint16x4x2_t r = vuzp_u16(vreinterpret_u16_s64(y), vreinterpret_u16_s64(x));
return vreinterpret_s64_u16(r.val[1]);
#endif
}
SIMD_INLINE v64 v64_unpacklo_s16_s32(v64 x) {
return vreinterpret_s64_s32(vget_low_s32(vmovl_s16(vreinterpret_s16_s64(x))));
}
SIMD_INLINE v64 v64_unpacklo_u16_s32(v64 x) {
return vreinterpret_s64_u32(vget_low_u32(vmovl_u16(vreinterpret_u16_s64(x))));
}
SIMD_INLINE v64 v64_unpackhi_s16_s32(v64 x) {
return vreinterpret_s64_s32(
vget_high_s32(vmovl_s16(vreinterpret_s16_s64(x))));
}
SIMD_INLINE v64 v64_unpackhi_u16_s32(v64 x) {
return vreinterpret_s64_u32(
vget_high_u32(vmovl_u16(vreinterpret_u16_s64(x))));
}
SIMD_INLINE v64 v64_shuffle_8(v64 x, v64 pattern) {
return vreinterpret_s64_u8(
vtbl1_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(pattern)));
}
SIMD_INLINE v64 v64_cmpgt_s8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vcgt_s8(vreinterpret_s8_s64(x), vreinterpret_s8_s64(y)));
}
SIMD_INLINE v64 v64_cmplt_s8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vclt_s8(vreinterpret_s8_s64(x), vreinterpret_s8_s64(y)));
}
SIMD_INLINE v64 v64_cmpeq_8(v64 x, v64 y) {
return vreinterpret_s64_u8(
vceq_u8(vreinterpret_u8_s64(x), vreinterpret_u8_s64(y)));
}
SIMD_INLINE v64 v64_cmpgt_s16(v64 x, v64 y) {
return vreinterpret_s64_u16(
vcgt_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_cmplt_s16(v64 x, v64 y) {
return vreinterpret_s64_u16(
vclt_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_cmpeq_16(v64 x, v64 y) {
return vreinterpret_s64_u16(
vceq_s16(vreinterpret_s16_s64(x), vreinterpret_s16_s64(y)));
}
SIMD_INLINE v64 v64_shl_8(v64 a, unsigned int c) {
return vreinterpret_s64_u8(vshl_u8(vreinterpret_u8_s64(a), vdup_n_s8(c)));
}
SIMD_INLINE v64 v64_shr_u8(v64 a, unsigned int c) {
return vreinterpret_s64_u8(vshl_u8(vreinterpret_u8_s64(a), vdup_n_s8(-c)));
}
SIMD_INLINE v64 v64_shr_s8(v64 a, unsigned int c) {
return vreinterpret_s64_s8(vshl_s8(vreinterpret_s8_s64(a), vdup_n_s8(-c)));
}
SIMD_INLINE v64 v64_shl_16(v64 a, unsigned int c) {
return vreinterpret_s64_u16(vshl_u16(vreinterpret_u16_s64(a), vdup_n_s16(c)));
}
SIMD_INLINE v64 v64_shr_u16(v64 a, unsigned int c) {
return vreinterpret_s64_u16(
vshl_u16(vreinterpret_u16_s64(a), vdup_n_s16(-(int)c)));
}
SIMD_INLINE v64 v64_shr_s16(v64 a, unsigned int c) {
return vreinterpret_s64_s16(
vshl_s16(vreinterpret_s16_s64(a), vdup_n_s16(-(int)c)));
}
SIMD_INLINE v64 v64_shl_32(v64 a, unsigned int c) {
return vreinterpret_s64_u32(vshl_u32(vreinterpret_u32_s64(a), vdup_n_s32(c)));
}
SIMD_INLINE v64 v64_shr_u32(v64 a, unsigned int c) {
return vreinterpret_s64_u32(
vshl_u32(vreinterpret_u32_s64(a), vdup_n_s32(-(int)c)));
}
SIMD_INLINE v64 v64_shr_s32(v64 a, unsigned int c) {
return vreinterpret_s64_s32(
vshl_s32(vreinterpret_s32_s64(a), vdup_n_s32(-(int)c)));
}
// The following functions require an immediate.
// Some compilers will check this during optimisation, others wont.
#if defined(__OPTIMIZE__) && __OPTIMIZE__ && !defined(__clang__)
SIMD_INLINE v64 v64_shl_n_byte(v64 a, unsigned int c) {
return vshl_n_s64(a, c * 8);
}
SIMD_INLINE v64 v64_shr_n_byte(v64 a, unsigned int c) {
return c ? (v64)vshr_n_u64(vreinterpret_u64_s64(a), c * 8) : a;
}
SIMD_INLINE v64 v64_shl_n_8(v64 a, unsigned int c) {
return c ? vreinterpret_s64_u8(vshl_n_u8(vreinterpret_u8_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_u8(v64 a, unsigned int c) {
return c ? vreinterpret_s64_u8(vshr_n_u8(vreinterpret_u8_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_s8(v64 a, unsigned int c) {
return c ? vreinterpret_s64_s8(vshr_n_s8(vreinterpret_s8_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shl_n_16(v64 a, unsigned int c) {
return c ? vreinterpret_s64_u16(vshl_n_u16(vreinterpret_u16_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_u16(v64 a, unsigned int c) {
return c ? vreinterpret_s64_u16(vshr_n_u16(vreinterpret_u16_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_s16(v64 a, unsigned int c) {
return c ? vreinterpret_s64_s16(vshr_n_s16(vreinterpret_s16_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shl_n_32(v64 a, unsigned int c) {
return c ? vreinterpret_s64_u32(vshl_n_u32(vreinterpret_u32_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_u32(v64 a, unsigned int c) {
return c ? vreinterpret_s64_u32(vshr_n_u32(vreinterpret_u32_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_s32(v64 a, unsigned int c) {
return c ? vreinterpret_s64_s32(vshr_n_s32(vreinterpret_s32_s64(a), c)) : a;
}
#else
SIMD_INLINE v64 v64_shl_n_byte(v64 a, unsigned int c) {
return v64_from_64(v64_u64(a) << c * 8);
}
SIMD_INLINE v64 v64_shr_n_byte(v64 a, unsigned int c) {
return v64_from_64(v64_u64(a) >> c * 8);
}
SIMD_INLINE v64 v64_shl_n_8(v64 a, unsigned int c) { return v64_shl_8(a, c); }
SIMD_INLINE v64 v64_shr_n_u8(v64 a, unsigned int c) { return v64_shr_u8(a, c); }
SIMD_INLINE v64 v64_shr_n_s8(v64 a, unsigned int c) { return v64_shr_s8(a, c); }
SIMD_INLINE v64 v64_shl_n_16(v64 a, unsigned int c) { return v64_shl_16(a, c); }
SIMD_INLINE v64 v64_shr_n_u16(v64 a, unsigned int c) {
return v64_shr_u16(a, c);
}
SIMD_INLINE v64 v64_shr_n_s16(v64 a, unsigned int c) {
return v64_shr_s16(a, c);
}
SIMD_INLINE v64 v64_shl_n_32(v64 a, unsigned int c) { return v64_shl_32(a, c); }
SIMD_INLINE v64 v64_shr_n_u32(v64 a, unsigned int c) {
return v64_shr_u32(a, c);
}
SIMD_INLINE v64 v64_shr_n_s32(v64 a, unsigned int c) {
return v64_shr_s32(a, c);
}
#endif
#endif // AOM_AOM_DSP_SIMD_V64_INTRINSICS_ARM_H_
|