-
Notifications
You must be signed in to change notification settings - Fork 133
/
sleefsimdsp.c
3652 lines (2936 loc) · 148 KB
/
sleefsimdsp.c
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 Naoki Shibata and contributors 2010 - 2021.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Always use -ffp-contract=off option to compile SLEEF.
#if !defined(SLEEF_GENHEADER)
#include <stdint.h>
#include <assert.h>
#include <limits.h>
#include <float.h>
#endif
#include "quaddef.h"
#include "misc.h"
#ifndef ENABLE_CUDA
extern const float Sleef_rempitabsp[];
#endif
#define __SLEEFSIMDSP_C__
#if defined(_MSC_VER) && !defined (__clang__)
#pragma fp_contract (off)
#endif
#pragma STDC FP_CONTRACT OFF
// Intel
#ifdef ENABLE_SSE2
#define CONFIG 2
#if !defined(SLEEF_GENHEADER)
#include "helpersse2.h"
#else
#include "macroonlySSE2.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renamesse2_gnuabi.h"
#else
#include "renamesse2.h"
#endif
#endif
#endif
#ifdef ENABLE_SSE4
#define CONFIG 4
#if !defined(SLEEF_GENHEADER)
#include "helpersse2.h"
#else
#include "macroonlySSE4.h"
#endif
#ifdef DORENAME
#include "renamesse4.h"
#endif
#endif
#ifdef ENABLE_AVX
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperavx.h"
#else
#include "macroonlyAVX.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renameavx_gnuabi.h"
#else
#include "renameavx.h"
#endif
#endif
#endif
#ifdef ENABLE_FMA4
#define CONFIG 4
#if !defined(SLEEF_GENHEADER)
#include "helperavx.h"
#else
#include "macroonlyFMA4.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renamefma4_gnuabi.h"
#else
#include "renamefma4.h"
#endif
#endif
#endif
#ifdef ENABLE_AVX2
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperavx2.h"
#else
#include "macroonlyAVX2.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renameavx2_gnuabi.h"
#else
#include "renameavx2.h"
#endif
#endif
#endif
#ifdef ENABLE_AVX2128
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperavx2_128.h"
#else
#include "macroonlyAVX2128.h"
#endif
#ifdef DORENAME
#include "renameavx2128.h"
#endif
#endif
#ifdef ENABLE_AVX512F
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperavx512f.h"
#else
#include "macroonlyAVX512F.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renameavx512f_gnuabi.h"
#else
#include "renameavx512f.h"
#endif
#endif
#endif
#ifdef ENABLE_AVX512FNOFMA
#define CONFIG 2
#if !defined(SLEEF_GENHEADER)
#include "helperavx512f.h"
#else
#include "macroonlyAVX512FNOFMA.h"
#endif
#ifdef DORENAME
#include "renameavx512fnofma.h"
#endif
#endif
// Arm
#ifdef ENABLE_ADVSIMD
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperadvsimd.h"
#else
#include "macroonlyADVSIMD.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renameadvsimd_gnuabi.h"
#else
#include "renameadvsimd.h"
#endif
#endif
#endif
#ifdef ENABLE_ADVSIMDNOFMA
#define CONFIG 2
#if !defined(SLEEF_GENHEADER)
#include "helperadvsimd.h"
#else
#include "macroonlyADVSIMDNOFMA.h"
#endif
#ifdef DORENAME
#include "renameadvsimdnofma.h"
#endif
#endif
#ifdef ENABLE_NEON32
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperneon32.h"
#endif
#ifdef DORENAME
#include "renameneon32.h"
#endif
#endif
#ifdef ENABLE_NEON32VFPV4
#define CONFIG 4
#if !defined(SLEEF_GENHEADER)
#include "helperneon32.h"
#endif
#ifdef DORENAME
#include "renameneon32vfpv4.h"
#endif
#endif
#ifdef ENABLE_SVE
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helpersve.h"
#else
#include "macroonlySVE.h"
#endif
#ifdef DORENAME
#ifdef ENABLE_GNUABI
#include "renamesve_gnuabi.h"
#else
#include "renamesve.h"
#endif /* ENABLE_GNUABI */
#endif /* DORENAME */
#endif /* ENABLE_SVE */
#ifdef ENABLE_SVENOFMA
#define CONFIG 2
#if !defined(SLEEF_GENHEADER)
#include "helpersve.h"
#else
#include "macroonlySVENOFMA.h"
#endif
#ifdef DORENAME
#include "renamesvenofma.h"
#endif /* DORENAME */
#endif /* ENABLE_SVE */
// IBM
#ifdef ENABLE_VSX
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperpower_128.h"
#else
#include "macroonlyVSX.h"
#endif
#ifdef DORENAME
#include "renamevsx.h"
#endif
#endif
#ifdef ENABLE_VSXNOFMA
#define CONFIG 2
#if !defined(SLEEF_GENHEADER)
#include "helperpower_128.h"
#else
#include "macroonlyVSXNOFMA.h"
#endif
#ifdef DORENAME
#include "renamevsxnofma.h"
#endif
#endif
#ifdef ENABLE_VSX3
#define CONFIG 3
#if !defined(SLEEF_GENHEADER)
#include "helperpower_128.h"
#else
#include "macroonlyVSX3.h"
#endif
#ifdef DORENAME
#include "renamevsx3.h"
#endif
#endif
#ifdef ENABLE_VSX3NOFMA
#define CONFIG 4
#if !defined(SLEEF_GENHEADER)
#include "helperpower_128.h"
#else
#include "macroonlyVSX3NOFMA.h"
#endif
#ifdef DORENAME
#include "renamevsx3nofma.h"
#endif
#endif
#ifdef ENABLE_VXE
#define CONFIG 140
#if !defined(SLEEF_GENHEADER)
#include "helpers390x_128.h"
#else
#include "macroonlyVXE.h"
#endif
#ifdef DORENAME
#include "renamevxe.h"
#endif
#endif
#ifdef ENABLE_VXENOFMA
#define CONFIG 141
#if !defined(SLEEF_GENHEADER)
#include "helpers390x_128.h"
#else
#include "macroonlyVXENOFMA.h"
#endif
#ifdef DORENAME
#include "renamevxenofma.h"
#endif
#endif
#ifdef ENABLE_VXE2
#define CONFIG 150
#if !defined(SLEEF_GENHEADER)
#include "helpers390x_128.h"
#else
#include "macroonlyVXE2.h"
#endif
#ifdef DORENAME
#include "renamevxe2.h"
#endif
#endif
#ifdef ENABLE_VXE2NOFMA
#define CONFIG 151
#if !defined(SLEEF_GENHEADER)
#include "helpers390x_128.h"
#else
#include "macroonlyVXE2NOFMA.h"
#endif
#ifdef DORENAME
#include "renamevxe2nofma.h"
#endif
#endif
// Generic
#ifdef ENABLE_VECEXT
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helpervecext.h"
#endif
#ifdef DORENAME
#include "renamevecext.h"
#endif
#endif
#ifdef ENABLE_PUREC
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperpurec.h"
#endif
#ifdef DORENAME
#include "renamepurec.h"
#endif
#endif
#ifdef ENABLE_PUREC_SCALAR
#define CONFIG 1
#if !defined(SLEEF_GENHEADER)
#include "helperpurec_scalar.h"
#else
#include "macroonlyPUREC_SCALAR.h"
#endif
#ifdef DORENAME
#include "renamepurec_scalar.h"
#endif
#endif
#ifdef ENABLE_PURECFMA_SCALAR
#define CONFIG 2
#if !defined(SLEEF_GENHEADER)
#include "helperpurec_scalar.h"
#else
#include "macroonlyPURECFMA_SCALAR.h"
#endif
#ifdef DORENAME
#include "renamepurecfma_scalar.h"
#endif
#endif
#ifdef ENABLE_CUDA
#define CONFIG 3
#if !defined(SLEEF_GENHEADER)
#include "helperpurec_scalar.h"
#else
#include "macroonlyCUDA.h"
#endif
#ifdef DORENAME
#include "renamecuda.h"
#endif
#endif
//
#define MLA(x, y, z) vmla_vf_vf_vf_vf((x), (y), (z))
#define C2V(c) vcast_vf_f(c)
#include "estrin.h"
//
#include "df.h"
static INLINE CONST VECTOR_CC vopmask visnegzero_vo_vf(vfloat d) {
return veq_vo_vi2_vi2(vreinterpret_vi2_vf(d), vreinterpret_vi2_vf(vcast_vf_f(-0.0)));
}
static INLINE VECTOR_CC vopmask vnot_vo32_vo32(vopmask x) {
return vxor_vo_vo_vo(x, veq_vo_vi2_vi2(vcast_vi2_i(0), vcast_vi2_i(0)));
}
static INLINE CONST VECTOR_CC vmask vsignbit_vm_vf(vfloat f) {
return vand_vm_vm_vm(vreinterpret_vm_vf(f), vreinterpret_vm_vf(vcast_vf_f(-0.0f)));
}
static INLINE CONST VECTOR_CC vfloat vmulsign_vf_vf_vf(vfloat x, vfloat y) {
return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(x), vsignbit_vm_vf(y)));
}
static INLINE CONST VECTOR_CC vfloat vcopysign_vf_vf_vf(vfloat x, vfloat y) {
return vreinterpret_vf_vm(vxor_vm_vm_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(x)),
vand_vm_vm_vm (vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(y))));
}
static INLINE CONST VECTOR_CC vfloat vsign_vf_vf(vfloat f) {
return vreinterpret_vf_vm(vor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(1.0f)), vand_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f))));
}
static INLINE CONST VECTOR_CC vopmask vsignbit_vo_vf(vfloat d) {
return veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vreinterpret_vi2_vf(d), vcast_vi2_i(0x80000000)), vcast_vi2_i(0x80000000));
}
static INLINE CONST VECTOR_CC vint2 vsel_vi2_vf_vf_vi2_vi2(vfloat f0, vfloat f1, vint2 x, vint2 y) {
return vsel_vi2_vo_vi2_vi2(vlt_vo_vf_vf(f0, f1), x, y);
}
static INLINE CONST VECTOR_CC vint2 vsel_vi2_vf_vi2(vfloat d, vint2 x) {
return vand_vi2_vo_vi2(vsignbit_vo_vf(d), x);
}
static INLINE CONST VECTOR_CC vopmask visint_vo_vf(vfloat y) { return veq_vo_vf_vf(vtruncate_vf_vf(y), y); }
static INLINE CONST VECTOR_CC vopmask visnumber_vo_vf(vfloat x) { return vnot_vo32_vo32(vor_vo_vo_vo(visinf_vo_vf(x), visnan_vo_vf(x))); }
#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA)
static INLINE CONST VECTOR_CC vint2 vilogbk_vi2_vf(vfloat d) {
vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(5.421010862427522E-20f));
d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(vcast_vf_f(1.8446744073709552E19f), d), d);
vint2 q = vand_vi2_vi2_vi2(vsrl_vi2_vi2_i(vreinterpret_vi2_vf(d), 23), vcast_vi2_i(0xff));
q = vsub_vi2_vi2_vi2(q, vsel_vi2_vo_vi2_vi2(o, vcast_vi2_i(64 + 0x7f), vcast_vi2_i(0x7f)));
return q;
}
static INLINE CONST VECTOR_CC vint2 vilogb2k_vi2_vf(vfloat d) {
vint2 q = vreinterpret_vi2_vf(d);
q = vsrl_vi2_vi2_i(q, 23);
q = vand_vi2_vi2_vi2(q, vcast_vi2_i(0xff));
q = vsub_vi2_vi2_vi2(q, vcast_vi2_i(0x7f));
return q;
}
#endif
//
EXPORT CONST VECTOR_CC vint2 xilogbf(vfloat d) {
vint2 e = vilogbk_vi2_vf(vabs_vf_vf(d));
e = vsel_vi2_vo_vi2_vi2(veq_vo_vf_vf(d, vcast_vf_f(0.0f)), vcast_vi2_i(SLEEF_FP_ILOGB0), e);
e = vsel_vi2_vo_vi2_vi2(visnan_vo_vf(d), vcast_vi2_i(SLEEF_FP_ILOGBNAN), e);
e = vsel_vi2_vo_vi2_vi2(visinf_vo_vf(d), vcast_vi2_i(SLEEF_INT_MAX), e);
return e;
}
static INLINE CONST VECTOR_CC vfloat vpow2i_vf_vi2(vint2 q) {
return vreinterpret_vf_vi2(vsll_vi2_vi2_i(vadd_vi2_vi2_vi2(q, vcast_vi2_i(0x7f)), 23));
}
static INLINE CONST VECTOR_CC vfloat vldexp_vf_vf_vi2(vfloat x, vint2 q) {
vfloat u;
vint2 m = vsra_vi2_vi2_i(q, 31);
m = vsll_vi2_vi2_i(vsub_vi2_vi2_vi2(vsra_vi2_vi2_i(vadd_vi2_vi2_vi2(m, q), 6), m), 4);
q = vsub_vi2_vi2_vi2(q, vsll_vi2_vi2_i(m, 2));
m = vadd_vi2_vi2_vi2(m, vcast_vi2_i(0x7f));
m = vand_vi2_vi2_vi2(vgt_vi2_vi2_vi2(m, vcast_vi2_i(0)), m);
vint2 n = vgt_vi2_vi2_vi2(m, vcast_vi2_i(0xff));
m = vor_vi2_vi2_vi2(vandnot_vi2_vi2_vi2(n, m), vand_vi2_vi2_vi2(n, vcast_vi2_i(0xff)));
u = vreinterpret_vf_vi2(vsll_vi2_vi2_i(m, 23));
x = vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(x, u), u), u), u);
u = vreinterpret_vf_vi2(vsll_vi2_vi2_i(vadd_vi2_vi2_vi2(q, vcast_vi2_i(0x7f)), 23));
return vmul_vf_vf_vf(x, u);
}
static INLINE CONST VECTOR_CC vfloat vldexp2_vf_vf_vi2(vfloat d, vint2 e) {
return vmul_vf_vf_vf(vmul_vf_vf_vf(d, vpow2i_vf_vi2(vsra_vi2_vi2_i(e, 1))), vpow2i_vf_vi2(vsub_vi2_vi2_vi2(e, vsra_vi2_vi2_i(e, 1))));
}
static INLINE CONST VECTOR_CC vfloat vldexp3_vf_vf_vi2(vfloat d, vint2 q) {
return vreinterpret_vf_vi2(vadd_vi2_vi2_vi2(vreinterpret_vi2_vf(d), vsll_vi2_vi2_i(q, 23)));
}
EXPORT CONST VECTOR_CC vfloat xldexpf(vfloat x, vint2 q) { return vldexp_vf_vf_vi2(x, q); }
#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA))
typedef struct {
vfloat d;
vint2 i;
} fi_t;
static vfloat figetd_vf_di(fi_t d) { return d.d; }
static vint2 figeti_vi2_di(fi_t d) { return d.i; }
static fi_t fisetdi_fi_vf_vi2(vfloat d, vint2 i) {
fi_t r = { d, i };
return r;
}
typedef struct {
vfloat2 df;
vint2 i;
} dfi_t;
static vfloat2 dfigetdf_vf2_dfi(dfi_t d) { return d.df; }
static vint2 dfigeti_vi2_dfi(dfi_t d) { return d.i; }
static dfi_t dfisetdfi_dfi_vf2_vi2(vfloat2 v, vint2 i) {
dfi_t r = { v, i };
return r;
}
static dfi_t dfisetdf_dfi_dfi_vf2(dfi_t dfi, vfloat2 v) {
dfi.df = v;
return dfi;
}
#endif
static INLINE CONST VECTOR_CC vfloat vorsign_vf_vf_vf(vfloat x, vfloat y) {
return vreinterpret_vf_vm(vor_vm_vm_vm(vreinterpret_vm_vf(x), vsignbit_vm_vf(y)));
}
static INLINE CONST fi_t rempisubf(vfloat x) {
#ifdef FULL_FP_ROUNDING
vfloat y = vrint_vf_vf(vmul_vf_vf_vf(x, vcast_vf_f(4)));
vint2 vi = vtruncate_vi2_vf(vsub_vf_vf_vf(y, vmul_vf_vf_vf(vrint_vf_vf(x), vcast_vf_f(4))));
return fisetdi_fi_vf_vi2(vsub_vf_vf_vf(x, vmul_vf_vf_vf(y, vcast_vf_f(0.25))), vi);
#else
vfloat c = vmulsign_vf_vf_vf(vcast_vf_f(1 << 23), x);
vfloat rint4x = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(vmul_vf_vf_vf(vcast_vf_f(4), x)), vcast_vf_f(1 << 23)),
vmul_vf_vf_vf(vcast_vf_f(4), x),
vorsign_vf_vf_vf(vsub_vf_vf_vf(vmla_vf_vf_vf_vf(vcast_vf_f(4), x, c), c), x));
vfloat rintx = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(1 << 23)),
x, vorsign_vf_vf_vf(vsub_vf_vf_vf(vadd_vf_vf_vf(x, c), c), x));
return fisetdi_fi_vf_vi2(vmla_vf_vf_vf_vf(vcast_vf_f(-0.25), rint4x, x),
vtruncate_vi2_vf(vmla_vf_vf_vf_vf(vcast_vf_f(-4), rintx, rint4x)));
#endif
}
static INLINE CONST dfi_t rempif(vfloat a) {
vfloat2 x, y;
vint2 ex = vilogb2k_vi2_vf(a);
#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA)
ex = vandnot_vi2_vi2_vi2(vsra_vi2_vi2_i(ex, 31), ex);
ex = vand_vi2_vi2_vi2(ex, vcast_vi2_i(127));
#endif
ex = vsub_vi2_vi2_vi2(ex, vcast_vi2_i(25));
vint2 q = vand_vi2_vo_vi2(vgt_vo_vi2_vi2(ex, vcast_vi2_i(90-25)), vcast_vi2_i(-64));
a = vldexp3_vf_vf_vi2(a, q);
ex = vandnot_vi2_vi2_vi2(vsra_vi2_vi2_i(ex, 31), ex);
ex = vsll_vi2_vi2_i(ex, 2);
x = dfmul_vf2_vf_vf(a, vgather_vf_p_vi2(Sleef_rempitabsp, ex));
fi_t di = rempisubf(vf2getx_vf_vf2(x));
q = figeti_vi2_di(di);
x = vf2setx_vf2_vf2_vf(x, figetd_vf_di(di));
x = dfnormalize_vf2_vf2(x);
y = dfmul_vf2_vf_vf(a, vgather_vf_p_vi2(Sleef_rempitabsp+1, ex));
x = dfadd2_vf2_vf2_vf2(x, y);
di = rempisubf(vf2getx_vf_vf2(x));
q = vadd_vi2_vi2_vi2(q, figeti_vi2_di(di));
x = vf2setx_vf2_vf2_vf(x, figetd_vf_di(di));
x = dfnormalize_vf2_vf2(x);
y = vcast_vf2_vf_vf(vgather_vf_p_vi2(Sleef_rempitabsp+2, ex), vgather_vf_p_vi2(Sleef_rempitabsp+3, ex));
y = dfmul_vf2_vf2_vf(y, a);
x = dfadd2_vf2_vf2_vf2(x, y);
x = dfnormalize_vf2_vf2(x);
x = dfmul_vf2_vf2_vf2(x, vcast_vf2_f_f(3.1415927410125732422f*2, -8.7422776573475857731e-08f*2));
x = vsel_vf2_vo_vf2_vf2(vlt_vo_vf_vf(vabs_vf_vf(a), vcast_vf_f(0.7f)), vcast_vf2_vf_vf(a, vcast_vf_f(0)), x);
return dfisetdfi_dfi_vf2_vi2(x, q);
}
EXPORT CONST VECTOR_CC vfloat xsinf(vfloat d) {
#if !defined(DETERMINISTIC)
vint2 q;
vfloat u, s, r = d;
if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) {
q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)));
u = vcast_vf_vi2(q);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f), d);
} else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) {
q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)));
u = vcast_vf_vi2(q);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df), d);
} else {
dfi_t dfi = rempif(d);
q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3));
q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1)));
q = vsra_vi2_vi2_i(q, 2);
vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1));
vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))),
vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))));
x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x);
dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi)));
d = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi)));
d = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(d)));
}
s = vmul_vf_vf_vf(d, d);
d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d)));
u = vcast_vf_f(2.6083159809786593541503e-06f);
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f));
u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d);
u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(r), r, u);
return u;
#else // #if !defined(DETERMINISTIC)
vint2 q;
vfloat u, s, r = d;
q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)));
u = vcast_vf_vi2(q);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f), d);
vopmask g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAX2f));
if (!LIKELY(vtestallones_i_vo32(g))) {
s = vcast_vf_vi2(q);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Af), r);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Bf), u);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Cf), u);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Df), u);
d = vsel_vf_vo_vf_vf(g, d, u);
g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAXf));
if (!LIKELY(vtestallones_i_vo32(g))) {
dfi_t dfi = rempif(r);
vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3));
q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1)));
q2 = vsra_vi2_vi2_i(q2, 2);
vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1));
vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))),
vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))));
x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x);
dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi)));
u = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi)));
u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(u)));
q = vsel_vi2_vo_vi2_vi2(g, q, q2);
d = vsel_vf_vo_vf_vf(g, d, u);
}
}
s = vmul_vf_vf_vf(d, d);
d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d)));
u = vcast_vf_f(2.6083159809786593541503e-06f);
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f));
u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d);
u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(r), r, u);
return u;
#endif // #if !defined(DETERMINISTIC)
}
EXPORT CONST VECTOR_CC vfloat xcosf(vfloat d) {
#if !defined(DETERMINISTIC)
vint2 q;
vfloat u, s, r = d;
if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) {
q = vrint_vi2_vf(vsub_vf_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)), vcast_vf_f(0.5f)));
q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vcast_vi2_i(1));
u = vcast_vf_vi2(q);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), d);
} else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) {
q = vrint_vi2_vf(vsub_vf_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)), vcast_vf_f(0.5f)));
q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vcast_vi2_i(1));
u = vcast_vf_vi2(q);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df*0.5f), d);
} else {
dfi_t dfi = rempif(d);
q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3));
q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(8), vcast_vi2_i(7)));
q = vsra_vi2_vi2_i(q, 1);
vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(0));
vfloat y = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vf_f(0), vcast_vf_f(-1));
vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), y),
vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), y));
x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x);
dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi)));
d = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi)));
d = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(d)));
}
s = vmul_vf_vf_vf(d, d);
d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d)));
u = vcast_vf_f(2.6083159809786593541503e-06f);
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f));
u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d);
return u;
#else // #if !defined(DETERMINISTIC)
vint2 q;
vfloat u, s, r = d;
q = vrint_vi2_vf(vsub_vf_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)), vcast_vf_f(0.5f)));
q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vcast_vi2_i(1));
u = vcast_vf_vi2(q);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), d);
d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), d);
vopmask g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAX2f));
if (!LIKELY(vtestallones_i_vo32(g))) {
s = vcast_vf_vi2(q);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Af*0.5f), r);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Bf*0.5f), u);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Cf*0.5f), u);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Df*0.5f), u);
d = vsel_vf_vo_vf_vf(g, d, u);
g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAXf));
if (!LIKELY(vtestallones_i_vo32(g))) {
dfi_t dfi = rempif(r);
vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3));
q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(8), vcast_vi2_i(7)));
q2 = vsra_vi2_vi2_i(q2, 1);
vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(0));
vfloat y = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vf_f(0), vcast_vf_f(-1));
vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), y),
vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), y));
x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x);
dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi)));
u = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi)));
u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(u)));
q = vsel_vi2_vo_vi2_vi2(g, q, q2);
d = vsel_vf_vo_vf_vf(g, d, u);
}
}
s = vmul_vf_vf_vf(d, d);
d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d)));
u = vcast_vf_f(2.6083159809786593541503e-06f);
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f));
u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d);
return u;
#endif // #if !defined(DETERMINISTIC)
}
EXPORT CONST VECTOR_CC vfloat xtanf(vfloat d) {
#if !defined(DETERMINISTIC)
vint2 q;
vopmask o;
vfloat u, s, x;
x = d;
if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f*0.5f))))) {
q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI))));
u = vcast_vf_vi2(q);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), x);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), x);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), x);
} else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) {
q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI))));
u = vcast_vf_vi2(q);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af*0.5f), x);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf*0.5f), x);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf*0.5f), x);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df*0.5f), x);
} else {
dfi_t dfi = rempif(d);
q = dfigeti_vi2_dfi(dfi);
x = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi)));
x = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(x)));
x = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, x);
}
s = vmul_vf_vf_vf(x, x);
o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1));
x = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(x)));
#if defined(ENABLE_NEON32)
u = vcast_vf_f(0.00927245803177356719970703f);
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00331984995864331722259521f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0242998078465461730957031f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0534495301544666290283203f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.133383005857467651367188f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.333331853151321411132812f));
#else
vfloat s2 = vmul_vf_vf_vf(s, s), s4 = vmul_vf_vf_vf(s2, s2);
u = POLY6(s, s2, s4,
0.00927245803177356719970703f,
0.00331984995864331722259521f,
0.0242998078465461730957031f,
0.0534495301544666290283203f,
0.133383005857467651367188f,
0.333331853151321411132812f);
#endif
u = vmla_vf_vf_vf_vf(s, vmul_vf_vf_vf(u, x), x);
u = vsel_vf_vo_vf_vf(o, vrec_vf_vf(u), u);
return u;
#else // #if !defined(DETERMINISTIC)
vint2 q;
vopmask o;
vfloat u, s, x;
q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI))));
u = vcast_vf_vi2(q);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), x);
x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), x);
vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f*0.5f));
if (!LIKELY(vtestallones_i_vo32(g))) {
vint2 q2 = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI))));
s = vcast_vf_vi2(q);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Af*0.5f), d);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Bf*0.5f), u);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Cf*0.5f), u);
u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Df*0.5f), u);
q = vsel_vi2_vo_vi2_vi2(g, q, q2);
x = vsel_vf_vo_vf_vf(g, x, u);
g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf));
if (!LIKELY(vtestallones_i_vo32(g))) {
dfi_t dfi = rempif(d);
u = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi)));
u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(u)));
u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u);
q = vsel_vi2_vo_vi2_vi2(g, q, dfigeti_vi2_dfi(dfi));
x = vsel_vf_vo_vf_vf(g, x, u);
}
}
s = vmul_vf_vf_vf(x, x);
o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1));
x = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(x)));
#if defined(ENABLE_NEON32)
u = vcast_vf_f(0.00927245803177356719970703f);
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00331984995864331722259521f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0242998078465461730957031f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0534495301544666290283203f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.133383005857467651367188f));
u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.333331853151321411132812f));
#else
vfloat s2 = vmul_vf_vf_vf(s, s), s4 = vmul_vf_vf_vf(s2, s2);
u = POLY6(s, s2, s4,
0.00927245803177356719970703f,
0.00331984995864331722259521f,
0.0242998078465461730957031f,
0.0534495301544666290283203f,
0.133383005857467651367188f,
0.333331853151321411132812f);
#endif
u = vmla_vf_vf_vf_vf(s, vmul_vf_vf_vf(u, x), x);
u = vsel_vf_vo_vf_vf(o, vrec_vf_vf(u), u);
return u;
#endif // #if !defined(DETERMINISTIC)
}
EXPORT CONST VECTOR_CC vfloat xsinf_u1(vfloat d) {
#if !defined(DETERMINISTIC)
vint2 q;
vfloat u, v;
vfloat2 s, t, x;
if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) {
u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(M_1_PI)));
q = vrint_vi2_vf(u);
v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d);
s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f)));
s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f)));
} else {
dfi_t dfi = rempif(d);
q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3));
q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1)));
q = vsra_vi2_vi2_i(q, 2);
vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1));
vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))),
vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))));
x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x);
dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi)));
s = dfnormalize_vf2_vf2(dfigetdf_vf2_dfi(dfi));
#if !defined(_MSC_VER)
s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(vf2getx_vf_vf2(s)))));
#else
s.x = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(s.x)));
#endif
}
t = s;
s = dfsqu_vf2_vf2(s);
u = vcast_vf_f(2.6083159809786593541503e-06f);
u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.0001981069071916863322258f));
u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833307858556509017944336f));
x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf(vcast_vf_f(-0.166666597127914428710938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))), s));
u = dfmul_vf_vf2_vf2(t, x);
u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(u)));
u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u);
return u;
#else // #if !defined(DETERMINISTIC)
vint2 q;
vfloat u, v;
vfloat2 s, t, x;
u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(M_1_PI)));
q = vrint_vi2_vf(u);
v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d);
s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f)));
s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f)));
vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f));
if (!LIKELY(vtestallones_i_vo32(g))) {
dfi_t dfi = rempif(d);
vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3));
q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1)));
q2 = vsra_vi2_vi2_i(q2, 2);
vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1));
vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))),
vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))));
x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x);
dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi)));
t = dfnormalize_vf2_vf2(dfigetdf_vf2_dfi(dfi));
t = vf2setx_vf2_vf2_vf(t, vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(vf2getx_vf_vf2(t)))));
q = vsel_vi2_vo_vi2_vi2(g, q, q2);
s = vsel_vf2_vo_vf2_vf2(g, s, t);
}
t = s;
s = dfsqu_vf2_vf2(s);
u = vcast_vf_f(2.6083159809786593541503e-06f);
u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.0001981069071916863322258f));
u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833307858556509017944336f));
x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf(vcast_vf_f(-0.166666597127914428710938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))), s));
u = dfmul_vf_vf2_vf2(t, x);