1/*
2Copyright (c) 2014, Intel Corporation
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8    * Redistributions of source code must retain the above copyright notice,
9    * this list of conditions and the following disclaimer.
10
11    * Redistributions in binary form must reproduce the above copyright notice,
12    * this list of conditions and the following disclaimer in the documentation
13    * and/or other materials provided with the distribution.
14
15    * Neither the name of Intel Corporation nor the names of its contributors
16    * may be used to endorse or promote products derived from this software
17    * without specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*/
30
31/******************************************************************************/
32//                     ALGORITHM DESCRIPTION
33//                     ---------------------
34//
35//   Assume x=2^{3*k+j} * 1.b1 b2 ... b5 b6 ... b52, where j = 0,1,2.
36//   Let r=(x*2^{-3k-j} - 1.b1 b2 ... b5 1)* rcp[b1 b2 ..b5],
37//   where rcp[b1 b2 .. b5]=1/(1.b1 b2 b3 b4 b5 1) in double precision
38//   cbrt(2^j * 1. b1 b2 .. b5 1) is approximated as T[j][b1..b5]+D[j][b1..b5]
39//   (T stores the high 53 bits, D stores the low order bits)
40//   Result=2^k*T+(2^k*T*r)*P+2^k*D
41//   where P=p1+p2*r+..+p8*r^7
42//
43// Special cases:
44//  cbrt(NaN) = quiet NaN, and raise invalid exception
45//  cbrt(INF) = that INF
46//  cbrt(+/-0) = +/-0
47//
48/******************************************************************************/
49
50#include <private/bionic_asm.h>
51# -- Begin  static_func
52        .text
53        .align __bionic_asm_align
54        .type static_func, @function
55static_func:
56..B1.1:
57        call      ..L2
58..L2:
59        popl      %eax
60        lea       _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax
61        lea       static_const_table@GOTOFF(%eax), %eax
62        ret
63        .size   static_func,.-static_func
64# -- End  static_func
65
66# -- Begin  cbrt
67ENTRY(cbrt)
68# parameter 1: 8 + %ebp
69..B2.1:
70..B2.2:
71        pushl     %ebp
72        movl      %esp, %ebp
73        subl      $120, %esp
74        movl      %esi, 52(%esp)
75        call      static_func
76        movl      %eax, %esi
77        movsd     128(%esp), %xmm0
78        movapd    %xmm0, %xmm7
79        movsd     %xmm0, 8(%esp)
80        movl      $524032, %edx
81        movsd     64(%esi), %xmm5
82        movsd     80(%esi), %xmm3
83        psrlq     $44, %xmm7
84        pextrw    $0, %xmm7, %ecx
85        movd      %xmm7, %eax
86        movsd     96(%esi), %xmm1
87        movsd     112(%esi), %xmm2
88        movl      %ebx, 16(%esp)
89        andl      $248, %ecx
90        movsd     128(%ecx,%esi), %xmm4
91        movl      %eax, %ebx
92        andl      %eax, %edx
93        cmpl      $0, %edx
94        je        .L_2TAG_PACKET_0.0.2
95        cmpl      $524032, %edx
96        je        .L_2TAG_PACKET_1.0.2
97        shrl      $8, %edx
98        shrl      $8, %ebx
99        andpd     %xmm0, %xmm2
100        andpd     %xmm5, %xmm0
101        orpd      %xmm2, %xmm3
102        orpd      %xmm0, %xmm1
103        movapd    (%esi), %xmm5
104        movl      $5462, %eax
105        movapd    16(%esi), %xmm6
106        mull      %edx
107        movl      %ebx, %edx
108        andl      $2047, %ebx
109        shrl      $14, %eax
110        andl      $2048, %edx
111        subl      %eax, %ebx
112        subl      %eax, %ebx
113        subl      %eax, %ebx
114        shll      $8, %ebx
115        addl      $682, %eax
116        orl       %edx, %eax
117        movd      %eax, %xmm7
118        addl      %ebx, %ecx
119        psllq     $52, %xmm7
120.L_2TAG_PACKET_2.0.2:
121        movapd    32(%esi), %xmm2
122        movapd    48(%esi), %xmm0
123        subsd     %xmm3, %xmm1
124        movq      %xmm7, %xmm3
125        mulsd     384(%ecx,%esi), %xmm7
126        mulsd     %xmm4, %xmm1
127        mulsd     1152(%ecx,%esi), %xmm3
128        movapd    %xmm1, %xmm4
129        unpcklpd  %xmm1, %xmm1
130        mulpd     %xmm1, %xmm5
131        mulpd     %xmm1, %xmm6
132        mulpd     %xmm1, %xmm1
133        addpd     %xmm5, %xmm2
134        addpd     %xmm6, %xmm0
135        mulpd     %xmm1, %xmm2
136        mulpd     %xmm1, %xmm1
137        mulsd     %xmm7, %xmm4
138        addpd     %xmm2, %xmm0
139        movl      16(%esp), %ebx
140        mulsd     %xmm0, %xmm1
141        unpckhpd  %xmm0, %xmm0
142        addsd     %xmm1, %xmm0
143        mulsd     %xmm4, %xmm0
144        addsd     %xmm3, %xmm0
145        addsd     %xmm7, %xmm0
146        movsd     %xmm0, (%esp)
147        fldl      (%esp)
148        jmp       .L_2TAG_PACKET_3.0.2
149.L_2TAG_PACKET_0.0.2:
150        mulsd     1984(%esi), %xmm0
151        movq      %xmm0, %xmm7
152        movl      $524032, %edx
153        psrlq     $44, %xmm7
154        pextrw    $0, %xmm7, %ecx
155        movd      %xmm7, %eax
156        andl      $248, %ecx
157        movsd     128(%ecx,%esi), %xmm4
158        movl      %eax, %ebx
159        andl      %eax, %edx
160        shrl      $8, %edx
161        shrl      $8, %ebx
162        cmpl      $0, %edx
163        je        .L_2TAG_PACKET_4.0.2
164        andpd     %xmm0, %xmm2
165        andpd     %xmm5, %xmm0
166        orpd      %xmm2, %xmm3
167        orpd      %xmm0, %xmm1
168        movapd    (%esi), %xmm5
169        movl      $5462, %eax
170        movapd    16(%esi), %xmm6
171        mull      %edx
172        movl      %ebx, %edx
173        andl      $2047, %ebx
174        shrl      $14, %eax
175        andl      $2048, %edx
176        subl      %eax, %ebx
177        subl      %eax, %ebx
178        subl      %eax, %ebx
179        shll      $8, %ebx
180        addl      $661, %eax
181        orl       %edx, %eax
182        movd      %eax, %xmm7
183        addl      %ebx, %ecx
184        psllq     $52, %xmm7
185        jmp       .L_2TAG_PACKET_2.0.2
186.L_2TAG_PACKET_4.0.2:
187        cmpl      $0, %ebx
188        jne       .L_2TAG_PACKET_5.0.2
189        movl      16(%esp), %ebx
190        fldl      1952(%esi)
191        jmp       .L_2TAG_PACKET_3.0.2
192.L_2TAG_PACKET_5.0.2:
193        movl      16(%esp), %ebx
194        fldl      1968(%esi)
195        jmp       .L_2TAG_PACKET_3.0.2
196.L_2TAG_PACKET_1.0.2:
197        movl      16(%esp), %ebx
198        movl      132(%esp), %eax
199        movl      128(%esp), %edx
200        movl      %eax, %ecx
201        andl      $2147483647, %ecx
202        cmpl      $2146435072, %ecx
203        ja        .L_2TAG_PACKET_6.0.2
204        cmpl      $0, %edx
205        jne       .L_2TAG_PACKET_6.0.2
206        cmpl      $2146435072, %eax
207        jne       .L_2TAG_PACKET_7.0.2
208        fldl      1920(%esi)
209        jmp       .L_2TAG_PACKET_3.0.2
210.L_2TAG_PACKET_7.0.2:
211        fldl      1936(%esi)
212        jmp       .L_2TAG_PACKET_3.0.2
213.L_2TAG_PACKET_6.0.2:
214        movsd     8(%esp), %xmm0
215        addsd     %xmm0, %xmm0
216        movsd     %xmm0, (%esp)
217        fldl      (%esp)
218.L_2TAG_PACKET_3.0.2:
219        movl      52(%esp), %esi
220        movl      %ebp, %esp
221        popl      %ebp
222        ret
223..B2.3:
224END(cbrt)
225# -- End  cbrt
226
227# Start file scope ASM
228ALIAS_SYMBOL(cbrtl, cbrt);
229# End file scope ASM
230	.section .rodata, "a"
231	.align 16
232	.align 16
233static_const_table:
234	.long	1553778919
235	.long	3213899486
236	.long	3534952507
237	.long	3215266280
238	.long	1646371399
239	.long	3214412045
240	.long	477218588
241	.long	3216798151
242	.long	3582521621
243	.long	1066628362
244	.long	1007461464
245	.long	1068473053
246	.long	889629714
247	.long	1067378449
248	.long	1431655765
249	.long	1070945621
250	.long	4294967295
251	.long	1048575
252	.long	0
253	.long	0
254	.long	0
255	.long	3220193280
256	.long	0
257	.long	0
258	.long	0
259	.long	3220176896
260	.long	0
261	.long	0
262	.long	0
263	.long	1032192
264	.long	0
265	.long	0
266	.long	528611360
267	.long	3220144632
268	.long	2884679527
269	.long	3220082993
270	.long	1991868891
271	.long	3220024928
272	.long	2298714891
273	.long	3219970134
274	.long	58835168
275	.long	3219918343
276	.long	3035110223
277	.long	3219869313
278	.long	1617585086
279	.long	3219822831
280	.long	2500867033
281	.long	3219778702
282	.long	4241943008
283	.long	3219736752
284	.long	258732970
285	.long	3219696825
286	.long	404232216
287	.long	3219658776
288	.long	2172167368
289	.long	3219622476
290	.long	1544257904
291	.long	3219587808
292	.long	377579543
293	.long	3219554664
294	.long	1616385542
295	.long	3219522945
296	.long	813783277
297	.long	3219492562
298	.long	3940743189
299	.long	3219463431
300	.long	2689777499
301	.long	3219435478
302	.long	1700977147
303	.long	3219408632
304	.long	3169102082
305	.long	3219382828
306	.long	327235604
307	.long	3219358008
308	.long	1244336319
309	.long	3219334115
310	.long	1300311200
311	.long	3219311099
312	.long	3095471925
313	.long	3219288912
314	.long	2166487928
315	.long	3219267511
316	.long	2913108253
317	.long	3219246854
318	.long	293672978
319	.long	3219226904
320	.long	288737297
321	.long	3219207624
322	.long	1810275472
323	.long	3219188981
324	.long	174592167
325	.long	3219170945
326	.long	3539053052
327	.long	3219153485
328	.long	2164392968
329	.long	3219136576
330	.long	572345495
331	.long	1072698681
332	.long	1998204467
333	.long	1072709382
334	.long	3861501553
335	.long	1072719872
336	.long	2268192434
337	.long	1072730162
338	.long	2981979308
339	.long	1072740260
340	.long	270859143
341	.long	1072750176
342	.long	2958651392
343	.long	1072759916
344	.long	313113243
345	.long	1072769490
346	.long	919449400
347	.long	1072778903
348	.long	2809328903
349	.long	1072788162
350	.long	2222981587
351	.long	1072797274
352	.long	2352530781
353	.long	1072806244
354	.long	594152517
355	.long	1072815078
356	.long	1555767199
357	.long	1072823780
358	.long	4282421314
359	.long	1072832355
360	.long	2355578597
361	.long	1072840809
362	.long	1162590619
363	.long	1072849145
364	.long	797864051
365	.long	1072857367
366	.long	431273680
367	.long	1072865479
368	.long	2669831148
369	.long	1072873484
370	.long	733477752
371	.long	1072881387
372	.long	4280220604
373	.long	1072889189
374	.long	801961634
375	.long	1072896896
376	.long	2915370760
377	.long	1072904508
378	.long	1159613482
379	.long	1072912030
380	.long	2689944798
381	.long	1072919463
382	.long	1248687822
383	.long	1072926811
384	.long	2967951030
385	.long	1072934075
386	.long	630170432
387	.long	1072941259
388	.long	3760898254
389	.long	1072948363
390	.long	0
391	.long	1072955392
392	.long	2370273294
393	.long	1072962345
394	.long	1261754802
395	.long	1072972640
396	.long	546334065
397	.long	1072986123
398	.long	1054893830
399	.long	1072999340
400	.long	1571187597
401	.long	1073012304
402	.long	1107975175
403	.long	1073025027
404	.long	3606909377
405	.long	1073037519
406	.long	1113616747
407	.long	1073049792
408	.long	4154744632
409	.long	1073061853
410	.long	3358931423
411	.long	1073073713
412	.long	4060702372
413	.long	1073085379
414	.long	747576176
415	.long	1073096860
416	.long	3023138255
417	.long	1073108161
418	.long	1419988548
419	.long	1073119291
420	.long	1914185305
421	.long	1073130255
422	.long	294389948
423	.long	1073141060
424	.long	3761802570
425	.long	1073151710
426	.long	978281566
427	.long	1073162213
428	.long	823148820
429	.long	1073172572
430	.long	2420954441
431	.long	1073182792
432	.long	3815449908
433	.long	1073192878
434	.long	2046058587
435	.long	1073202835
436	.long	1807524753
437	.long	1073212666
438	.long	2628681401
439	.long	1073222375
440	.long	3225667357
441	.long	1073231966
442	.long	1555307421
443	.long	1073241443
444	.long	3454043099
445	.long	1073250808
446	.long	1208137896
447	.long	1073260066
448	.long	3659916772
449	.long	1073269218
450	.long	1886261264
451	.long	1073278269
452	.long	3593647839
453	.long	1073287220
454	.long	3086012205
455	.long	1073296075
456	.long	2769796922
457	.long	1073304836
458	.long	888716057
459	.long	1073317807
460	.long	2201465623
461	.long	1073334794
462	.long	164369365
463	.long	1073351447
464	.long	3462666733
465	.long	1073367780
466	.long	2773905457
467	.long	1073383810
468	.long	1342879088
469	.long	1073399550
470	.long	2543933975
471	.long	1073415012
472	.long	1684477781
473	.long	1073430209
474	.long	3532178543
475	.long	1073445151
476	.long	1147747300
477	.long	1073459850
478	.long	1928031793
479	.long	1073474314
480	.long	2079717015
481	.long	1073488553
482	.long	4016765315
483	.long	1073502575
484	.long	3670431139
485	.long	1073516389
486	.long	3549227225
487	.long	1073530002
488	.long	11637607
489	.long	1073543422
490	.long	588220169
491	.long	1073556654
492	.long	2635407503
493	.long	1073569705
494	.long	2042029317
495	.long	1073582582
496	.long	1925128962
497	.long	1073595290
498	.long	4136375664
499	.long	1073607834
500	.long	759964600
501	.long	1073620221
502	.long	4257606771
503	.long	1073632453
504	.long	297278907
505	.long	1073644538
506	.long	3655053093
507	.long	1073656477
508	.long	2442253172
509	.long	1073668277
510	.long	1111876799
511	.long	1073679941
512	.long	3330973139
513	.long	1073691472
514	.long	3438879452
515	.long	1073702875
516	.long	3671565478
517	.long	1073714153
518	.long	1317849547
519	.long	1073725310
520	.long	1642364115
521	.long	1073736348
522	.long	4050900474
523	.long	1014427190
524	.long	1157977860
525	.long	1016444461
526	.long	1374568199
527	.long	1017271387
528	.long	2809163288
529	.long	1016882676
530	.long	3742377377
531	.long	1013168191
532	.long	3101606597
533	.long	1017541672
534	.long	65224358
535	.long	1017217597
536	.long	2691591250
537	.long	1017266643
538	.long	4020758549
539	.long	1017689313
540	.long	1316310992
541	.long	1018030788
542	.long	1031537856
543	.long	1014090882
544	.long	3261395239
545	.long	1016413641
546	.long	886424999
547	.long	1016313335
548	.long	3114776834
549	.long	1014195875
550	.long	1681120620
551	.long	1017825416
552	.long	1329600273
553	.long	1016625740
554	.long	465474623
555	.long	1017097119
556	.long	4251633980
557	.long	1017169077
558	.long	1986990133
559	.long	1017710645
560	.long	752958613
561	.long	1017159641
562	.long	2216216792
563	.long	1018020163
564	.long	4282860129
565	.long	1015924861
566	.long	1557627859
567	.long	1016039538
568	.long	3889219754
569	.long	1018086237
570	.long	3684996408
571	.long	1017353275
572	.long	723532103
573	.long	1017717141
574	.long	2951149676
575	.long	1012528470
576	.long	831890937
577	.long	1017830553
578	.long	1031212645
579	.long	1017387331
580	.long	2741737450
581	.long	1017604974
582	.long	2863311531
583	.long	1003776682
584	.long	4276736099
585	.long	1013153088
586	.long	4111778382
587	.long	1015673686
588	.long	1728065769
589	.long	1016413986
590	.long	2708718031
591	.long	1018078833
592	.long	1069335005
593	.long	1015291224
594	.long	700037144
595	.long	1016482032
596	.long	2904566452
597	.long	1017226861
598	.long	4074156649
599	.long	1017622651
600	.long	25019565
601	.long	1015245366
602	.long	3601952608
603	.long	1015771755
604	.long	3267129373
605	.long	1017904664
606	.long	503203103
607	.long	1014921629
608	.long	2122011730
609	.long	1018027866
610	.long	3927295461
611	.long	1014189456
612	.long	2790625147
613	.long	1016024251
614	.long	1330460186
615	.long	1016940346
616	.long	4033568463
617	.long	1015538390
618	.long	3695818227
619	.long	1017509621
620	.long	257573361
621	.long	1017208868
622	.long	3227697852
623	.long	1017337964
624	.long	234118548
625	.long	1017169577
626	.long	4009025803
627	.long	1017278524
628	.long	1948343394
629	.long	1017749310
630	.long	678398162
631	.long	1018144239
632	.long	3083864863
633	.long	1016669086
634	.long	2415453452
635	.long	1017890370
636	.long	175467344
637	.long	1017330033
638	.long	3197359580
639	.long	1010339928
640	.long	2071276951
641	.long	1015941358
642	.long	268372543
643	.long	1016737773
644	.long	938132959
645	.long	1017389108
646	.long	1816750559
647	.long	1017337448
648	.long	4119203749
649	.long	1017152174
650	.long	2578653878
651	.long	1013108497
652	.long	2470331096
653	.long	1014678606
654	.long	123855735
655	.long	1016553320
656	.long	1265650889
657	.long	1014782687
658	.long	3414398172
659	.long	1017182638
660	.long	1040773369
661	.long	1016158401
662	.long	3483628886
663	.long	1016886550
664	.long	4140499405
665	.long	1016191425
666	.long	3893477850
667	.long	1016964495
668	.long	3935319771
669	.long	1009634717
670	.long	2978982660
671	.long	1015027112
672	.long	2452709923
673	.long	1017990229
674	.long	3190365712
675	.long	1015835149
676	.long	4237588139
677	.long	1015832925
678	.long	2610678389
679	.long	1017962711
680	.long	2127316774
681	.long	1017405770
682	.long	824267502
683	.long	1017959463
684	.long	2165924042
685	.long	1017912225
686	.long	2774007076
687	.long	1013257418
688	.long	4123916326
689	.long	1017582284
690	.long	1976417958
691	.long	1016959909
692	.long	4092806412
693	.long	1017711279
694	.long	119251817
695	.long	1015363631
696	.long	3475418768
697	.long	1017675415
698	.long	1972580503
699	.long	1015470684
700	.long	815541017
701	.long	1017517969
702	.long	2429917451
703	.long	1017397776
704	.long	4062888482
705	.long	1016749897
706	.long	68284153
707	.long	1017925678
708	.long	2207779246
709	.long	1016320298
710	.long	1183466520
711	.long	1017408657
712	.long	143326427
713	.long	1017060403
714	.long	0
715	.long	2146435072
716	.long	0
717	.long	0
718	.long	0
719	.long	4293918720
720	.long	0
721	.long	0
722	.long	0
723	.long	0
724	.long	0
725	.long	0
726	.long	0
727	.long	2147483648
728	.long	0
729	.long	0
730	.long	0
731	.long	1138753536
732	.long	0
733	.long	0
734	.type	static_const_table,@object
735	.size	static_const_table,2000
736	.data
737	.section .note.GNU-stack, ""
738# End
739