-
Notifications
You must be signed in to change notification settings - Fork 41
/
avxintrin.h
2268 lines (2004 loc) · 68.9 KB
/
avxintrin.h
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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AVX2NEON_H
#error Never use <avxintrin.h> directly; include " avx2neon.h" instead.
#endif
#include <arm_neon.h>
#include <math.h>
#ifdef __cplusplus
using namespace std;
#endif
#include "typedefs.h"
typedef union {
int8x16_t vect_s8[2];
int16x8_t vect_s16[2];
int32x4_t vect_s32[2];
int64x2_t vect_s64[2];
uint8x16_t vect_u8[2];
uint16x8_t vect_u16[2];
uint32x4_t vect_u32[2];
uint64x2_t vect_u64[2];
__m128i vect_i128[2];
} __m256i __attribute__((aligned(32)));
typedef struct {
float32x4_t vect_f32[2];
} __m256;
typedef struct {
float64x2_t vect_f64[2];
} __m256d;
#define _CMP_EQ_OQ 0x00
#define _CMP_LT_OS 0x01
#define _CMP_LE_OS 0x02
#define _CMP_UNORD_Q 0x03
#define _CMP_NEQ_UQ 0x04
#define _CMP_NLT_US 0x05
#define _CMP_NLE_US 0x06
#define _CMP_ORD_Q 0x07
#define _CMP_EQ_UQ 0x08
#define _CMP_NGE_US 0x09
#define _CMP_NGT_US 0x0a
#define _CMP_FALSE_OQ 0x0b
#define _CMP_NEQ_OQ 0x0c
#define _CMP_GE_OS 0x0d
#define _CMP_GT_OS 0x0e
#define _CMP_TRUE_UQ 0x0f
#define _CMP_EQ_OS 0x10
#define _CMP_LT_OQ 0x11
#define _CMP_LE_OQ 0x12
#define _CMP_UNORD_S 0x13
#define _CMP_NEQ_US 0x14
#define _CMP_NLT_UQ 0x15
#define _CMP_NLE_UQ 0x16
#define _CMP_ORD_S 0x17
#define _CMP_EQ_US 0x18
#define _CMP_NGE_UQ 0x19
#define _CMP_NGT_UQ 0x1a
#define _CMP_FALSE_OS 0x1b
#define _CMP_NEQ_OS 0x1c
#define _CMP_GE_OQ 0x1d
#define _CMP_GT_OQ 0x1e
#define _CMP_TRUE_US 0x1f
FORCE_INLINE __m256i _mm256_setzero_si256(void)
{
__m256i ret;
ret.vect_s32[0] = ret.vect_s32[1] = vdupq_n_s32(0);
return ret;
}
FORCE_INLINE __m256 _mm256_setzero_ps(void)
{
__m256 ret;
ret.vect_f32[0] = ret.vect_f32[1] = vdupq_n_f32(0.0f);
return ret;
}
FORCE_INLINE __m256d _mm256_setzero_pd(void)
{
__m256d ret;
ret.vect_f64[0] = ret.vect_f64[1] = vdupq_n_f64(0.0);
return ret;
}
FORCE_INLINE void _mm256_convert_to_int32(int32_t* ptr_a, __m256i a)
{
ptr_a[0] = vgetq_lane_s32(a.vect_s32[0], 0);
ptr_a[1] = vgetq_lane_s32(a.vect_s32[0], 1);
ptr_a[2] = vgetq_lane_s32(a.vect_s32[0], 2);
ptr_a[3] = vgetq_lane_s32(a.vect_s32[0], 3);
ptr_a[4] = vgetq_lane_s32(a.vect_s32[1], 0);
ptr_a[5] = vgetq_lane_s32(a.vect_s32[1], 1);
ptr_a[6] = vgetq_lane_s32(a.vect_s32[1], 2);
ptr_a[7] = vgetq_lane_s32(a.vect_s32[1], 3);
}
FORCE_INLINE void _mm256_convert_to_int64(int64_t* ptr_a, __m256i a)
{
ptr_a[0] = vgetq_lane_s64(a.vect_s64[0], 0);
ptr_a[1] = vgetq_lane_s64(a.vect_s64[0], 1);
ptr_a[2] = vgetq_lane_s64(a.vect_s64[1], 0);
ptr_a[3] = vgetq_lane_s64(a.vect_s64[1], 1);
}
FORCE_INLINE void _mm256_convert_to_uint32(uint32_t* ptr_a, __m256i a)
{
ptr_a[0] = vgetq_lane_u32(a.vect_u32[0], 0);
ptr_a[1] = vgetq_lane_u32(a.vect_u32[0], 1);
ptr_a[2] = vgetq_lane_u32(a.vect_u32[0], 2);
ptr_a[3] = vgetq_lane_u32(a.vect_u32[0], 3);
ptr_a[4] = vgetq_lane_u32(a.vect_u32[1], 0);
ptr_a[5] = vgetq_lane_u32(a.vect_u32[1], 1);
ptr_a[6] = vgetq_lane_u32(a.vect_u32[1], 2);
ptr_a[7] = vgetq_lane_u32(a.vect_u32[1], 3);
}
FORCE_INLINE void _mm256_convert_to_uint64(uint64_t* ptr_a, __m256i a)
{
ptr_a[0] = vgetq_lane_u64(a.vect_u64[0], 0);
ptr_a[1] = vgetq_lane_u64(a.vect_u64[0], 1);
ptr_a[2] = vgetq_lane_u64(a.vect_u64[1], 0);
ptr_a[3] = vgetq_lane_u64(a.vect_u64[1], 1);
}
FORCE_INLINE __m256i _mm256_div_epi8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_i128[0] = _mm_div_epi8(a.vect_i128[0], b.vect_i128[0]);
res_m256i.vect_i128[1] = _mm_div_epi8(a.vect_i128[1], b.vect_i128[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_div_epi16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_i128[0] = _mm_div_epi16(a.vect_i128[0], b.vect_i128[0]);
res_m256i.vect_i128[1] = _mm_div_epi16(a.vect_i128[1], b.vect_i128[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_div_epi32(__m256i a, __m256i b)
{
__m256i res = _mm256_setzero_si256();
int32_t ptr_a[8], ptr_b[8], ptr_r[8];
_mm256_convert_to_int32(ptr_a, a);
_mm256_convert_to_int32(ptr_b, b);
ptr_r[0] = ptr_a[0] / ptr_b[0];
ptr_r[1] = ptr_a[1] / ptr_b[1];
ptr_r[2] = ptr_a[2] / ptr_b[2];
ptr_r[3] = ptr_a[3] / ptr_b[3];
ptr_r[4] = ptr_a[4] / ptr_b[4];
ptr_r[5] = ptr_a[5] / ptr_b[5];
ptr_r[6] = ptr_a[6] / ptr_b[6];
ptr_r[7] = ptr_a[7] / ptr_b[7];
res.vect_s32[0] = vsetq_lane_s32(ptr_r[0], res.vect_s32[0], 0);
res.vect_s32[0] = vsetq_lane_s32(ptr_r[1], res.vect_s32[0], 1);
res.vect_s32[0] = vsetq_lane_s32(ptr_r[2], res.vect_s32[0], 2);
res.vect_s32[0] = vsetq_lane_s32(ptr_r[3], res.vect_s32[0], 3);
res.vect_s32[1] = vsetq_lane_s32(ptr_r[4], res.vect_s32[1], 0);
res.vect_s32[1] = vsetq_lane_s32(ptr_r[5], res.vect_s32[1], 1);
res.vect_s32[1] = vsetq_lane_s32(ptr_r[6], res.vect_s32[1], 2);
res.vect_s32[1] = vsetq_lane_s32(ptr_r[7], res.vect_s32[1], 3);
return res;
}
FORCE_INLINE __m256i _mm256_div_epi64(__m256i a, __m256i b)
{
__m256i res = _mm256_setzero_si256();
int64_t ptr_a[4], ptr_b[4], ptr_r[4];
_mm256_convert_to_int64(ptr_a, a);
_mm256_convert_to_int64(ptr_b, b);
ptr_r[0] = ptr_a[0] / ptr_b[0];
ptr_r[1] = ptr_a[1] / ptr_b[1];
ptr_r[2] = ptr_a[2] / ptr_b[2];
ptr_r[3] = ptr_a[3] / ptr_b[3];
res.vect_s64[0] = vsetq_lane_s64(ptr_r[0], res.vect_s64[0], 0);
res.vect_s64[0] = vsetq_lane_s64(ptr_r[1], res.vect_s64[0], 1);
res.vect_s64[1] = vsetq_lane_s64(ptr_r[2], res.vect_s64[1], 0);
res.vect_s64[1] = vsetq_lane_s64(ptr_r[3], res.vect_s64[1], 1);
return res;
}
FORCE_INLINE __m256i _mm256_div_epu8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_i128[0] = _mm_div_epu8(a.vect_i128[0], b.vect_i128[0]);
res_m256i.vect_i128[1] = _mm_div_epu8(a.vect_i128[1], b.vect_i128[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_div_epu16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_i128[0] = _mm_div_epu16(a.vect_i128[0], b.vect_i128[0]);
res_m256i.vect_i128[1] = _mm_div_epu16(a.vect_i128[1], b.vect_i128[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_div_epu32(__m256i a, __m256i b)
{
__m256i res = _mm256_setzero_si256();
uint32_t ptr_a[8], ptr_b[8], ptr_r[8];
_mm256_convert_to_uint32(ptr_a, a);
_mm256_convert_to_uint32(ptr_b, b);
ptr_r[0] = ptr_a[0] / ptr_b[0];
ptr_r[1] = ptr_a[1] / ptr_b[1];
ptr_r[2] = ptr_a[2] / ptr_b[2];
ptr_r[3] = ptr_a[3] / ptr_b[3];
ptr_r[4] = ptr_a[4] / ptr_b[4];
ptr_r[5] = ptr_a[5] / ptr_b[5];
ptr_r[6] = ptr_a[6] / ptr_b[6];
ptr_r[7] = ptr_a[7] / ptr_b[7];
res.vect_u32[0] = vsetq_lane_u32(ptr_r[0], res.vect_u32[0], 0);
res.vect_u32[0] = vsetq_lane_u32(ptr_r[1], res.vect_u32[0], 1);
res.vect_u32[0] = vsetq_lane_u32(ptr_r[2], res.vect_u32[0], 2);
res.vect_u32[0] = vsetq_lane_u32(ptr_r[3], res.vect_u32[0], 3);
res.vect_u32[1] = vsetq_lane_u32(ptr_r[4], res.vect_u32[1], 0);
res.vect_u32[1] = vsetq_lane_u32(ptr_r[5], res.vect_u32[1], 1);
res.vect_u32[1] = vsetq_lane_u32(ptr_r[6], res.vect_u32[1], 2);
res.vect_u32[1] = vsetq_lane_u32(ptr_r[7], res.vect_u32[1], 3);
return res;
}
FORCE_INLINE __m256i _mm256_div_epu64(__m256i a, __m256i b)
{
__m256i res = _mm256_setzero_si256();
uint64_t ptr_a[4], ptr_b[4], ptr_r[4];
_mm256_convert_to_uint64(ptr_a, a);
_mm256_convert_to_uint64(ptr_b, b);
ptr_r[0] = ptr_a[0] / ptr_b[0];
ptr_r[1] = ptr_a[1] / ptr_b[1];
ptr_r[2] = ptr_a[2] / ptr_b[2];
ptr_r[3] = ptr_a[3] / ptr_b[3];
res.vect_u64[0] = vsetq_lane_u64(ptr_r[0], res.vect_u64[0], 0);
res.vect_u64[0] = vsetq_lane_u64(ptr_r[1], res.vect_u64[0], 1);
res.vect_u64[1] = vsetq_lane_u64(ptr_r[2], res.vect_u64[1], 0);
res.vect_u64[1] = vsetq_lane_u64(ptr_r[3], res.vect_u64[1], 1);
return res;
}
FORCE_INLINE __m256 _mm256_div_ps(__m256 a, __m256 b)
{
__m256 res_m256;
res_m256.vect_f32[0] = vdivq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m256.vect_f32[1] = vdivq_f32(a.vect_f32[1], b.vect_f32[1]);
return res_m256;
}
FORCE_INLINE __m256d _mm256_div_pd(__m256d a, __m256d b)
{
__m256d res_m256d;
res_m256d.vect_f64[0] = vdivq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m256d.vect_f64[1] = vdivq_f64(a.vect_f64[1], b.vect_f64[1]);
return res_m256d;
}
FORCE_INLINE __m256i _mm256_add_epi8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s8[0] = vaddq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m256i.vect_s8[1] = vaddq_s8(a.vect_s8[1], b.vect_s8[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_add_epi16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s16[0] = vaddq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m256i.vect_s16[1] = vaddq_s16(a.vect_s16[1], b.vect_s16[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_add_epi32(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = vaddq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m256i.vect_s32[1] = vaddq_s32(a.vect_s32[1], b.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_add_epi64(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s64[0] = vaddq_s64(a.vect_s64[0], b.vect_s64[0]);
res_m256i.vect_s64[1] = vaddq_s64(a.vect_s64[1], b.vect_s64[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_adds_epi8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s8[0] = vqaddq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m256i.vect_s8[1] = vqaddq_s8(a.vect_s8[1], b.vect_s8[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_adds_epi16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s16[0] = vqaddq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m256i.vect_s16[1] = vqaddq_s16(a.vect_s16[1], b.vect_s16[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_adds_epu8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_u8[0] = vqaddq_u8(a.vect_u8[0], b.vect_u8[0]);
res_m256i.vect_u8[1] = vqaddq_u8(a.vect_u8[1], b.vect_u8[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_adds_epu16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_u16[0] = vqaddq_u16(a.vect_u16[0], b.vect_u16[0]);
res_m256i.vect_u16[1] = vqaddq_u16(a.vect_u16[1], b.vect_u16[1]);
return res_m256i;
}
FORCE_INLINE __m256 _mm256_add_ps(__m256 a, __m256 b)
{
__m256 res_m256;
res_m256.vect_f32[0] = vaddq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m256.vect_f32[1] = vaddq_f32(a.vect_f32[1], b.vect_f32[1]);
return res_m256;
}
FORCE_INLINE __m256d _mm256_add_pd(__m256d a, __m256d b)
{
__m256d res_m256d;
res_m256d.vect_f64[0] = vaddq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m256d.vect_f64[1] = vaddq_f64(a.vect_f64[1], b.vect_f64[1]);
return res_m256d;
}
FORCE_INLINE __m256 _mm256_addsub_ps (__m256 a, __m256 b)
{
__m256 c = _mm256_setzero_ps();
__asm__ __volatile__ (
"fsub %2.4s, %0.4s, %4.4s \n\t"
"fsub %3.4s, %1.4s, %5.4s \n\t"
"fadd %0.4s, %0.4s, %4.4s \n\t"
"fadd %1.4s, %1.4s, %5.4s \n\t"
"mov %2.s[1], %0.s[1] \n\t"
"mov %3.s[1], %1.s[1] \n\t"
"mov %2.s[3], %0.s[3] \n\t"
"mov %3.s[3], %1.s[3] \n\t"
:"+w"(a.vect_f32[0]), "+w"(a.vect_f32[1]), "+w"(c.vect_f32[0]), "+w"(c.vect_f32[1])
:"w"(b.vect_f32[0]), "w"(b.vect_f32[1])
);
return c;
}
FORCE_INLINE __m256d _mm256_addsub_pd (__m256d a, __m256d b)
{
__m256d c = _mm256_setzero_pd();
__asm__ __volatile__ (
"fsub %2.2d, %0.2d, %4.2d \n\t"
"fsub %3.2d, %1.2d, %5.2d \n\t"
"fadd %0.2d, %0.2d, %4.2d \n\t"
"fadd %1.2d, %1.2d, %5.2d \n\t"
"mov %2.d[1], %0.d[1] \n\t"
"mov %3.d[1], %1.d[1] \n\t"
:"+w"(a.vect_f64[0]), "+w"(a.vect_f64[1]), "+w"(c.vect_f64[0]), "+w"(c.vect_f64[1])
:"w"(b.vect_f64[0]), "w"(b.vect_f64[1])
);
return c;
}
FORCE_INLINE __m256i _mm256_sub_epi16 (__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s16[0] = vsubq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m256i.vect_s16[1] = vsubq_s16(a.vect_s16[1], b.vect_s16[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_sub_epi32(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = vsubq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m256i.vect_s32[1] = vsubq_s32(a.vect_s32[1], b.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_sub_epi64(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s64[0] = vsubq_s64(a.vect_s64[0], b.vect_s64[0]);
res_m256i.vect_s64[1] = vsubq_s64(a.vect_s64[1], b.vect_s64[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_sub_epi8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s8[0] = vsubq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m256i.vect_s8[1] = vsubq_s8(a.vect_s8[1], b.vect_s8[1]);
return res_m256i;
}
FORCE_INLINE __m256d _mm256_sub_pd(__m256d a, __m256d b)
{
__m256d res_m256d;
res_m256d.vect_f64[0] = vsubq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m256d.vect_f64[1] = vsubq_f64(a.vect_f64[1], b.vect_f64[1]);
return res_m256d;
}
FORCE_INLINE __m256 _mm256_sub_ps(__m256 a, __m256 b)
{
__m256 res_m256;
res_m256.vect_f32[0] = vsubq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m256.vect_f32[1] = vsubq_f32(a.vect_f32[1], b.vect_f32[1]);
return res_m256;
}
FORCE_INLINE __m256i _mm256_subs_epi16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s16[0] = vqsubq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m256i.vect_s16[1] = vqsubq_s16(a.vect_s16[1], b.vect_s16[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_subs_epi8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s8[0] = vqsubq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m256i.vect_s8[1] = vqsubq_s8(a.vect_s8[1], b.vect_s8[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_subs_epu16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_u16[0] = vqsubq_u16(a.vect_u16[0], b.vect_u16[0]);
res_m256i.vect_u16[1] = vqsubq_u16(a.vect_u16[1], b.vect_u16[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_subs_epu8(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_u8[0] = vqsubq_u8(a.vect_u8[0], b.vect_u8[0]);
res_m256i.vect_u8[1] = vqsubq_u8(a.vect_u8[1], b.vect_u8[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_mul_epi32(__m256i a, __m256i b)
{
__asm__ __volatile__ (
"ins %[a0].s[1], %[a0].s[2] \n\t"
"ins %[a1].s[1], %[a1].s[2] \n\t"
"ins %[b0].s[1], %[b0].s[2] \n\t"
"ins %[b1].s[1], %[b1].s[2] \n\t"
"smull %[a0].2d, %[a0].2s, %[b0].2s \n\t"
"smull %[a1].2d, %[a1].2s, %[b1].2s \n\t"
:[a0]"+w"(a.vect_s32[0]), [a1]"+w"(a.vect_s32[1]), [b0]"+w"(b.vect_s32[0]), [b1]"+w"(b.vect_s32[1])
:
:
);
return a;
}
FORCE_INLINE __m256i _mm256_mul_epu32(__m256i a, __m256i b)
{
__asm__ __volatile__ (
"ins %[a0].s[1], %[a0].s[2] \n\t"
"ins %[a1].s[1], %[a1].s[2] \n\t"
"ins %[b0].s[1], %[b0].s[2] \n\t"
"ins %[b1].s[1], %[b1].s[2] \n\t"
"umull %[a0].2d, %[a0].2s, %[b0].2s \n\t"
"umull %[a1].2d, %[a1].2s, %[b1].2s \n\t"
:[a0]"+w"(a.vect_u32[0]), [a1]"+w"(a.vect_u32[1]), [b0]"+w"(b.vect_u32[0]), [b1]"+w"(b.vect_u32[1])
:
:
);
return a;
}
FORCE_INLINE __m256d _mm256_mul_pd(__m256d a, __m256d b)
{
__m256d res_m256d;
res_m256d.vect_f64[0] = vmulq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m256d.vect_f64[1] = vmulq_f64(a.vect_f64[1], b.vect_f64[1]);
return res_m256d;
}
FORCE_INLINE __m256 _mm256_mul_ps(__m256 a, __m256 b)
{
__m256 res_m256;
res_m256.vect_f32[0] = vmulq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m256.vect_f32[1] = vmulq_f32(a.vect_f32[1], b.vect_f32[1]);
return res_m256;
}
FORCE_INLINE __m256i _mm256_mulhi_epi16(__m256i a, __m256i b)
{
__asm__ __volatile__ (
"mov v4.d[0], %[a0].d[1] \n\t"
"mov v5.d[0], %[a1].d[1] \n\t"
"smull %[a0].4s, %[a0].4h, %[b0].4h \n\t"
"mov v6.d[0], %[b0].d[1] \n\t"
"mov v7.d[0], %[b1].d[1] \n\t"
"smull %[b0].4s, v4.4h, v6.4h \n\t"
"uzp2 %[a0].8h, %[a0].8h, %[b0].8h \n\t"
"smull %[a1].4s, %[a1].4h, %[b1].4h \n\t"
"smull %[b1].4s, v5.4h, v7.4h \n\t"
"uzp2 %[a1].8h, %[a1].8h, %[b1].8h \n\t"
:[a0]"+w"(a.vect_s16[0]), [a1]"+w"(a.vect_s16[1]), [b0]"+w"(b.vect_s16[0]), [b1]"+w"(b.vect_s16[1])
:
:"v4", "v5", "v6", "v7"
);
return a;
}
FORCE_INLINE __m256i _mm256_mulhi_epu16(__m256i a, __m256i b)
{
__asm__ __volatile__ (
"mov v4.d[0], %[a0].d[1] \n\t"
"mov v5.d[0], %[a1].d[1] \n\t"
"umull %[a0].4s, %[a0].4h, %[b0].4h \n\t"
"mov v6.d[0], %[b0].d[1] \n\t"
"mov v7.d[0], %[b1].d[1] \n\t"
"umull %[b0].4s, v4.4h, v6.4h \n\t"
"uzp2 %[a0].8h, %[a0].8h, %[b0].8h \n\t"
"umull %[a1].4s, %[a1].4h, %[b1].4h \n\t"
"umull %[b1].4s, v5.4h, v7.4h \n\t"
"uzp2 %[a1].8h, %[a1].8h, %[b1].8h \n\t"
:[a0]"+w"(a.vect_u16[0]), [a1]"+w"(a.vect_u16[1]), [b0]"+w"(b.vect_u16[0]), [b1]"+w"(b.vect_u16[1])
:
:"v4", "v5", "v6", "v7"
);
return a;
}
FORCE_INLINE __m256i _mm256_mulhi_epi32(__m256i a, __m256i b)
{
__asm__ __volatile__ (
"mov v4.d[0], %[a0].d[1] \n\t"
"mov v5.d[0], %[a1].d[1] \n\t"
"smull %[a0].2d, %[a0].2s, %[b0].2s \n\t"
"mov v6.d[0], %[b0].d[1] \n\t"
"mov v7.d[0], %[b1].d[1] \n\t"
"smull %[b0].2d, v4.2s, v6.2s \n\t"
"uzp2 %[a0].4s, %[a0].4s, %[b0].4s \n\t"
"smull %[a1].2d, %[a1].2s, %[b1].2s \n\t"
"smull %[b1].2d, v5.2s, v7.2s \n\t"
"uzp2 %[a1].4s, %[a1].4s, %[b1].4s \n\t"
:[a0]"+w"(a.vect_s32[0]), [a1]"+w"(a.vect_s32[1]), [b0]"+w"(b.vect_s32[0]), [b1]"+w"(b.vect_s32[1])
:
:"v4", "v5", "v6", "v7"
);
return a;
}
FORCE_INLINE __m256i _mm256_mulhi_epu32(__m256i a, __m256i b)
{
__asm__ __volatile__ (
"mov v4.d[0], %[a0].d[1] \n\t"
"mov v5.d[0], %[a1].d[1] \n\t"
"umull %[a0].2d, %[a0].2s, %[b0].2s \n\t"
"mov v6.d[0], %[b0].d[1] \n\t"
"mov v7.d[0], %[b1].d[1] \n\t"
"umull %[b0].2d, v4.2s, v6.2s \n\t"
"uzp2 %[a0].4s, %[a0].4s, %[b0].4s \n\t"
"umull %[a1].2d, %[a1].2s, %[b1].2s \n\t"
"umull %[b1].2d, v5.2s, v7.2s \n\t"
"uzp2 %[a1].4s, %[a1].4s, %[b1].4s \n\t"
:[a0]"+w"(a.vect_s32[0]), [a1]"+w"(a.vect_s32[1]), [b0]"+w"(b.vect_s32[0]), [b1]"+w"(b.vect_s32[1])
:
:"v4", "v5", "v6", "v7"
);
return a;
}
FORCE_INLINE __m256i _mm256_mullo_epi16(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s16[0] = vmulq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m256i.vect_s16[1] = vmulq_s16(a.vect_s16[1], b.vect_s16[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_mullo_epi32(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = vmulq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m256i.vect_s32[1] = vmulq_s32(a.vect_s32[1], b.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_mullo_epi64(__m256i a, __m256i b)
{
__m256i res = _mm256_setzero_si256();
int64_t ptr_a[4], ptr_b[4], ptr_r[4];
_mm256_convert_to_int64(ptr_a, a);
_mm256_convert_to_int64(ptr_b, b);
ptr_r[0] = ptr_a[0] * ptr_b[0];
ptr_r[1] = ptr_a[1] * ptr_b[1];
ptr_r[2] = ptr_a[2] * ptr_b[2];
ptr_r[3] = ptr_a[3] * ptr_b[3];
res.vect_s64[0] = vsetq_lane_s64(ptr_r[0], res.vect_s64[0], 0);
res.vect_s64[0] = vsetq_lane_s64(ptr_r[1], res.vect_s64[0], 1);
res.vect_s64[1] = vsetq_lane_s64(ptr_r[2], res.vect_s64[1], 0);
res.vect_s64[1] = vsetq_lane_s64(ptr_r[3], res.vect_s64[1], 1);
return res;
}
FORCE_INLINE __m256i _mm256_mulhrs_epi16(__m256i a, __m256i b)
{
__m256i res;
int32x4_t r_0 = vmull_s16(vget_low_s16(a.vect_s16[0]), vget_low_s16(b.vect_s16[0]));
int32x4_t r_1 = vmull_s16(vget_low_s16(a.vect_s16[1]), vget_low_s16(b.vect_s16[1]));
int32x4_t r_2 = vmull_s16(vget_high_s16(a.vect_s16[0]), vget_high_s16(b.vect_s16[0]));
int32x4_t r_3 = vmull_s16(vget_high_s16(a.vect_s16[1]), vget_high_s16(b.vect_s16[1]));
int32x4_t inc = vdupq_n_s32(0x00004000);
r_0 = vshrq_n_s32(vaddq_s32(r_0, inc), 15);
r_1 = vshrq_n_s32(vaddq_s32(r_1, inc), 15);
r_2 = vshrq_n_s32(vaddq_s32(r_2, inc), 15);
r_3 = vshrq_n_s32(vaddq_s32(r_3, inc), 15);
res.vect_s16[0] = vuzp1q_s16(vreinterpretq_s16_s32(r_0), vreinterpretq_s16_s32(r_2));
res.vect_s16[1] = vuzp1q_s16(vreinterpretq_s16_s32(r_1), vreinterpretq_s16_s32(r_3));
return res;
}
FORCE_INLINE void _mm256_zeroupper(void)
{
return; // 256位寄存器高128位置0,arm寄存器最大128位,该接口不作为
}
FORCE_INLINE __m256i _mm256_sll_epi32(__m256i a, __m128i count)
{
long long c = count.vect_s64[0];
__m256i result_m256i;
if (likely(c >= 0 && c < 32)) {
result_m256i.vect_s32[0] = vshlq_n_s32(a.vect_s32[0], c);
result_m256i.vect_s32[1] = vshlq_n_s32(a.vect_s32[1], c);
} else {
result_m256i.vect_s32[0] = vdupq_n_s32(0);
result_m256i.vect_s32[1] = vdupq_n_s32(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_sll_epi64(__m256i a, __m128i count)
{
long long c = count.vect_s64[0];
__m256i result_m256i;
if (likely(c >= 0 && c < 64)) {
result_m256i.vect_s64[0] = vshlq_n_s64(a.vect_s64[0], c);
result_m256i.vect_s64[1] = vshlq_n_s64(a.vect_s64[1], c);
} else {
result_m256i.vect_s64[0] = vdupq_n_s64(0);
result_m256i.vect_s64[1] = vdupq_n_s64(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_slli_epi32(__m256i a, int imm8)
{
__m256i result_m256i;
if (likely(imm8 >= 0 && imm8 < 32)) {
result_m256i.vect_s32[0] = vshlq_n_s32(a.vect_s32[0], imm8);
result_m256i.vect_s32[1] = vshlq_n_s32(a.vect_s32[1], imm8);
} else {
result_m256i.vect_s32[0] = vdupq_n_s32(0);
result_m256i.vect_s32[1] = vdupq_n_s32(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_slli_epi64(__m256i a, int imm8)
{
__m256i result_m256i;
if (likely(imm8 >= 0 && imm8 < 64)) {
result_m256i.vect_s64[0] = vshlq_n_s64(a.vect_s64[0], imm8);
result_m256i.vect_s64[1] = vshlq_n_s64(a.vect_s64[1], imm8);
} else {
result_m256i.vect_s64[0] = vdupq_n_s64(0);
result_m256i.vect_s64[1] = vdupq_n_s64(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_srli_epi64(__m256i a, int imm8)
{
__m256i result_m256i;
if (likely(imm8 >= 0 && imm8 < 64)) {
int64x2_t vect_imm = vdupq_n_s64(-imm8);
result_m256i.vect_u64[0] = vshlq_u64(a.vect_u64[0], vect_imm);
result_m256i.vect_u64[1] = vshlq_u64(a.vect_u64[1], vect_imm);
} else {
result_m256i.vect_u64[0] = vdupq_n_u64(0);
result_m256i.vect_u64[1] = vdupq_n_u64(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_slli_si256(__m256i a, const int imm8)
{
assert(imm8 >=0 && imm8 <256);
__m256i result_m256i;
if (likely(imm8 > 0 && imm8 <= 15)) {
result_m256i.vect_s8[0] = vextq_s8(vdupq_n_s8(0), a.vect_s8[0], 16 - imm8);
result_m256i.vect_s8[1] = vextq_s8(vdupq_n_s8(0), a.vect_s8[1], 16 - imm8);
} else if (imm8 == 0) {
result_m256i = a;
} else {
result_m256i.vect_s8[0] = vdupq_n_s8(0);
result_m256i.vect_s8[1] = vdupq_n_s8(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_srli_si256(__m256i a, const int imm8)
{
assert(imm8 >=0 && imm8 <256);
__m256i result_m256i;
if (likely(imm8 > 0 && imm8 <= 15)) {
result_m256i.vect_s8[0] = vextq_s8(a.vect_s8[0], vdupq_n_s8(0), imm8);
result_m256i.vect_s8[1] = vextq_s8(a.vect_s8[1], vdupq_n_s8(0), imm8);
} else if (imm8 == 0) {
result_m256i = a;
} else {
result_m256i.vect_s8[0] = vdupq_n_s8(0);
result_m256i.vect_s8[1] = vdupq_n_s8(0);
}
return result_m256i;
}
FORCE_INLINE __m256i _mm256_unpackhi_epi8(__m256i a, __m256i b)
{
__m256i result_m256i;
result_m256i.vect_s8[0] = vzip2q_s8(a.vect_s8[0], b.vect_s8[0]);
result_m256i.vect_s8[1] = vzip2q_s8(a.vect_s8[1], b.vect_s8[1]);
return result_m256i;
}
FORCE_INLINE __m256i _mm256_unpacklo_epi8(__m256i a, __m256i b)
{
__m256i result_m256i;
result_m256i.vect_s8[0] = vzip1q_s8(a.vect_s8[0], b.vect_s8[0]);
result_m256i.vect_s8[1] = vzip1q_s8(a.vect_s8[1], b.vect_s8[1]);
return result_m256i;
}
FORCE_INLINE __m256i _mm256_and_si256(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = vandq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m256i.vect_s32[1] = vandq_s32(a.vect_s32[1], b.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_andnot_si256(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = vbicq_s32(b.vect_s32[0], a.vect_s32[0]);
res_m256i.vect_s32[1] = vbicq_s32(b.vect_s32[1], a.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_xor_si256(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = veorq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m256i.vect_s32[1] = veorq_s32(a.vect_s32[1], b.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m256 _mm256_or_ps (__m256 a, __m256 b)
{
__asm__ __volatile(
"orr %0.16b, %0.16b, %2.16b \n\t"
"orr %1.16b, %1.16b, %3.16b \n\t"
:"+w"(a.vect_f32[0]), "+w"(a.vect_f32[1])
:"w"(b.vect_f32[0]), "w"(b.vect_f32[1])
);
return a;
}
FORCE_INLINE __m256d _mm256_or_pd (__m256d a, __m256d b)
{
__asm__ __volatile(
"orr %0.16b, %0.16b, %2.16b \n\t"
"orr %1.16b, %1.16b, %3.16b \n\t"
:"+w"(a.vect_f64[0]), "+w"(a.vect_f64[1])
:"w"(b.vect_f64[0]), "w"(b.vect_f64[1])
);
return a;
}
FORCE_INLINE int _mm256_movemask_epi8 (__m256i a)
{
int res;
__asm__ __volatile__ (
"ushr %[a0].16b, %[a0].16b, #7 \n\t"
"ushr %[a1].16b, %[a1].16b, #7 \n\t"
"usra %[a0].8h, %[a0].8h, #7 \n\t"
"usra %[a1].8h, %[a1].8h, #7 \n\t"
"usra %[a0].4s, %[a0].4s, #14 \n\t"
"usra %[a1].4s, %[a1].4s, #14 \n\t"
"usra %[a0].2d, %[a0].2d, #28 \n\t"
"usra %[a1].2d, %[a1].2d, #28 \n\t"
"ins %[a0].b[1], %[a0].b[8] \n\t"
"ins %[a0].b[2], %[a1].b[0] \n\t"
"ins %[a0].b[3], %[a1].b[8] \n\t"
"umov %w[r], %[a0].s[0]"
:[r]"=r"(res), [a0]"+w"(a.vect_u8[0]), [a1]"+w"(a.vect_u8[1])
:
:
);
return res;
}
FORCE_INLINE int _mm256_movemask_ps(__m256 a)
{
__m256i res_m256i;
res_m256i.vect_u32[0] = vshrq_n_u32(vreinterpretq_u32_f32(a.vect_f32[0]), 31);
res_m256i.vect_u32[1] = vshrq_n_u32(vreinterpretq_u32_f32(a.vect_f32[1]), 31);
res_m256i.vect_u64[0] = vsraq_n_u64(res_m256i.vect_u64[0], res_m256i.vect_u64[0], 31);
res_m256i.vect_u64[1] = vsraq_n_u64(res_m256i.vect_u64[1], res_m256i.vect_u64[1], 31);
return (int)(vgetq_lane_u8(res_m256i.vect_u8[0], 0) | (vgetq_lane_u8(res_m256i.vect_u8[0], 8) << 2) |
(vgetq_lane_u8(res_m256i.vect_u8[1], 0) << 4) | (vgetq_lane_u8(res_m256i.vect_u8[1], 8) << 6));
}
FORCE_INLINE int _mm256_testz_si256(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s64[0] = vandq_s64(a.vect_s64[0], b.vect_s64[0]);
res_m256i.vect_s64[1] = vandq_s64(a.vect_s64[1], b.vect_s64[1]);
int64x2_t tmp = vorrq_s64(res_m256i.vect_s64[0], res_m256i.vect_s64[1]);
return !(vgetq_lane_s64(tmp, 0) | vgetq_lane_s64(tmp, 1));
}
FORCE_INLINE __m256i _mm256_or_si256(__m256i a, __m256i b)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = vorrq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m256i.vect_s32[1] = vorrq_s32(a.vect_s32[1], b.vect_s32[1]);
return res_m256i;
}
FORCE_INLINE __m128i _mm256_extracti128_si256(__m256i a, const int imm8)
{
assert(imm8 >= 0 && imm8 <= 1);
__m128i res_m128i;
res_m128i.vect_s64 = a.vect_s64[imm8];
return res_m128i;
}
FORCE_INLINE __int32 _mm256_extract_epi32 (__m256i a, const int index)
{
assert(index >= 0 && index <= 7);
return a.vect_s32[!!(index & 0x04)][index & 0x03];
}
FORCE_INLINE __int64 _mm256_extract_epi64 (__m256i a, const int index)
{
assert(index >= 0 && index <= 3);
return a.vect_s64[!!(index & 0x02)][index & 0x01];
}
FORCE_INLINE __m128 _mm256_extractf128_ps (__m256 a, const int imm8)
{
assert(imm8 >= 0 && imm8 <= 1);
return a.vect_f32[imm8];
}
FORCE_INLINE __m128d _mm256_extractf128_pd (__m256d a, const int imm8)
{
assert(imm8 >= 0 && imm8 <= 1);
return a.vect_f64[imm8];
}
FORCE_INLINE __m256i _mm256_permute4x64_epi64(__m256i a, const int imm8)
{
__m256i res = _mm256_setzero_si256();
int64_t ptr_a[4];
vst1q_s64(ptr_a, a.vect_s64[0]);
vst1q_s64(ptr_a + 2, a.vect_s64[1]);
const int id0 = imm8 & 0x03;
const int id1 = (imm8 >> 2) & 0x03;
const int id2 = (imm8 >> 4) & 0x03;
const int id3 = (imm8 >> 6) & 0x03;
res.vect_s64[0] = vsetq_lane_s64(ptr_a[id0], res.vect_s64[0], 0);
res.vect_s64[0] = vsetq_lane_s64(ptr_a[id1], res.vect_s64[0], 1);
res.vect_s64[1] = vsetq_lane_s64(ptr_a[id2], res.vect_s64[1], 0);
res.vect_s64[1] = vsetq_lane_s64(ptr_a[id3], res.vect_s64[1], 1);
return res;
}
FORCE_INLINE __m256i _mm256_permute2f128_si256 (__m256i a, __m256i b, int imm8)
{
__m256i res;
int bit_0 = imm8 & 0x1, bit_1 = imm8 & 0x2, bit_3 = imm8 & 0x8;
if (bit_1 == 0) {
res.vect_s32[0] = a.vect_s32[bit_0];
} else {
res.vect_s32[0] = b.vect_s32[bit_0];
}
if (bit_3) {
res.vect_s32[0] = vdupq_n_s32(0);
}
bit_0 = (imm8 & 0x10) >> 4, bit_1 = imm8 & 0x20, bit_3 = imm8 & 0x80;
if (bit_1 == 0) {
res.vect_s32[1] = a.vect_s32[bit_0];
} else {
res.vect_s32[1] = b.vect_s32[bit_0];
}
if (bit_3) {
res.vect_s32[1] = vdupq_n_s32(0);
}
return res;
}
FORCE_INLINE __m256i _mm256_set_epi32(int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0)
{
__m256i res_m256i;
SET32x4(res_m256i.vect_s32[0], e0, e1, e2, e3);
SET32x4(res_m256i.vect_s32[1], e4, e5, e6, e7);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_set_epi64x(int64_t e3, int64_t e2, int64_t e1, int64_t e0)
{
__m256i res_m256i;
SET64x2(res_m256i.vect_s64[0], e0, e1);
SET64x2(res_m256i.vect_s64[1], e2, e3);
return res_m256i;
}
FORCE_INLINE __m256i _mm256_set_m128i(__m128i hi, __m128i lo)
{
__m256i res_m256i;
res_m256i.vect_s32[0] = lo.vect_s32;
res_m256i.vect_s32[1] = hi.vect_s32;
return res_m256i;
}
FORCE_INLINE __m256 _mm256_set_ps(float e7, float e6, float e5, float e4, float e3, float e2, float e1, float e0)
{
__m256 res_m256;
SET32x4(res_m256.vect_f32[0], e0, e1, e2, e3);
SET32x4(res_m256.vect_f32[1], e4, e5, e6, e7);
return res_m256;
}
FORCE_INLINE __m256d _mm256_set_pd(double e3, double e2, double e1, double e0)
{
__m256d res_m256d;
SET64x2(res_m256d.vect_f64[0], e0, e1);
SET64x2(res_m256d.vect_f64[1], e2, e3);
return res_m256d;
}
FORCE_INLINE __m256i _mm256_set1_epi8(int8_t a)
{
__m256i ret;
ret.vect_s8[0] = ret.vect_s8[1] = vdupq_n_s8(a);
return ret;
}
FORCE_INLINE __m256i _mm256_set1_epi32(int32_t a)
{
__m256i ret;
ret.vect_s32[0] = ret.vect_s32[1] = vdupq_n_s32(a);
return ret;
}
FORCE_INLINE __m256i _mm256_set1_epi64x(int64_t a)
{
__m256i ret;
ret.vect_s64[0] = ret.vect_s64[1] = vdupq_n_s64(a);
return ret;
}