this repo has no description
1/*
2 * log1pl by Ian Ollmann
3 *
4 * Copyright � 2005 Apple Computer, Inc. All Rights Reserved
5 *
6 */
7
8#include <machine/asm.h>
9
10#define LOCAL_STACK_SIZE 4
11#include "abi.h"
12
13ENTRY(log1pl)
14 SUBP $LOCAL_STACK_SIZE, STACKP
15 movl $0x3e95f619, (STACKP) // 1- sqrt(0.5f)
16
17 //test to see if |x| < 1-sqrt(2)/2
18 fldln2 // { ln2 }
19 fld1 // { 1, ln2 }
20 fchs // { -1, ln2 }
21 fldt FIRST_ARG_OFFSET(STACKP) // { x, -1, ln2 }
22 fucomi %st(1), %st(0) // { x, -1, ln2 }
23 jb log1pl_negnan
24
25 fld %st(0) // { x, x, -1, ln2 }
26 fabs // { |x|, x, -1, ln2 }
27 flds (STACKP) // { 1- sqrt(0.5f), |x|, x, -1, ln2 }
28 fucomip %st(1), %st(0) // { |x|, x, -1, ln2 }
29 fstp %st(0) // { x, -1, ln2 }
30 jb log1pl_large // handle (1-sqrt(2)/2) <= |x|
31
32 //we assume the common case is the one where the precision is needed
33 fstp %st(1) // { x, ln2 }
34 fyl2xp1 // { result }
35 ADDP $LOCAL_STACK_SIZE, STACKP
36 ret
37
38log1pl_negnan: // { x, -1, ln2 }
39 //we assume the common case is the one where the precision is needed
40 fstp %st(1) // { x, ln2 }
41 fyl2x // { result }
42 ADDP $LOCAL_STACK_SIZE, STACKP
43 ret
44
45
46//handles inputs outside of +-{ 1 - sqrt(2)/2 } and NaN
47log1pl_large: // { x+1, ln2 }
48 fsubp // { x+1, ln2 }
49 fyl2x // { result }
50
51 ADDP $LOCAL_STACK_SIZE, STACKP
52 ret
53
54