| OLD | NEW |
| 1 /* ix87 specific implementation of pow function. | 1 /* ix87 specific implementation of pow function. |
| 2 Copyright (C) 1996, 1997, 1999, 2001, 2004, 2005, 2007 | 2 Copyright (C) 1996, 1997, 1999, 2001, 2004, 2005, 2007 |
| 3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
| 4 This file is part of the GNU C Library. | 4 This file is part of the GNU C Library. |
| 5 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | 5 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. |
| 6 | 6 |
| 7 The GNU C Library is free software; you can redistribute it and/or | 7 The GNU C Library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Lesser General Public | 8 modify it under the terms of the GNU Lesser General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2.1 of the License, or (at your option) any later version. | 10 version 2.1 of the License, or (at your option) any later version. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 6: shrl $1, %edx | 131 6: shrl $1, %edx |
| 132 jnc 5f | 132 jnc 5f |
| 133 fxch | 133 fxch |
| 134 fmul %st(1) // x : ST*x | 134 fmul %st(1) // x : ST*x |
| 135 fxch | 135 fxch |
| 136 5: fmul %st(0), %st // x*x : ST*x | 136 5: fmul %st(0), %st // x*x : ST*x |
| 137 testl %edx, %edx | 137 testl %edx, %edx |
| 138 jnz 6b | 138 jnz 6b |
| 139 fstp %st(0) // ST*x | 139 fstp %st(0) // ST*x |
| 140 » ret | 140 » NACLRET |
| 141 | 141 |
| 142 /* y is ±NAN */ | 142 /* y is ±NAN */ |
| 143 30: flds 4(%esp) // x : y | 143 30: flds 4(%esp) // x : y |
| 144 fldl MO(one) // 1.0 : x : y | 144 fldl MO(one) // 1.0 : x : y |
| 145 fucomp %st(1) // x : y | 145 fucomp %st(1) // x : y |
| 146 fnstsw | 146 fnstsw |
| 147 sahf | 147 sahf |
| 148 je 31f | 148 je 31f |
| 149 fxch // y : x | 149 fxch // y : x |
| 150 31: fstp %st(1) | 150 31: fstp %st(1) |
| 151 » ret | 151 » NACLRET |
| 152 | 152 |
| 153 cfi_adjust_cfa_offset (4) | 153 cfi_adjust_cfa_offset (4) |
| 154 .align ALIGNARG(4) | 154 .align ALIGNARG(4) |
| 155 2: /* y is a real number. */ | 155 2: /* y is a real number. */ |
| 156 fxch // x : y | 156 fxch // x : y |
| 157 fldl MO(one) // 1.0 : x : y | 157 fldl MO(one) // 1.0 : x : y |
| 158 fldl MO(limit) // 0.29 : 1.0 : x : y | 158 fldl MO(limit) // 0.29 : 1.0 : x : y |
| 159 fld %st(2) // x : 0.29 : 1.0 : x : y | 159 fld %st(2) // x : 0.29 : 1.0 : x : y |
| 160 fsub %st(2) // x-1 : 0.29 : 1.0 : x : y | 160 fsub %st(2) // x-1 : 0.29 : 1.0 : x : y |
| 161 fabs // |x-1| : 0.29 : 1.0 : x : y | 161 fabs // |x-1| : 0.29 : 1.0 : x : y |
| (...skipping 11 matching lines...) Expand all Loading... |
| 173 fst %st(1) // y*log2(x) : y*log2(x) | 173 fst %st(1) // y*log2(x) : y*log2(x) |
| 174 frndint // int(y*log2(x)) : y*log2(x) | 174 frndint // int(y*log2(x)) : y*log2(x) |
| 175 fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) | 175 fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) |
| 176 fxch // fract(y*log2(x)) : int(y*log2(x)) | 176 fxch // fract(y*log2(x)) : int(y*log2(x)) |
| 177 f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x)) | 177 f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x)) |
| 178 faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) | 178 faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) |
| 179 fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*l
og2(x)) | 179 fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*l
og2(x)) |
| 180 addl $4, %esp | 180 addl $4, %esp |
| 181 cfi_adjust_cfa_offset (-4) | 181 cfi_adjust_cfa_offset (-4) |
| 182 fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) | 182 fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) |
| 183 » ret | 183 » NACLRET |
| 184 | 184 |
| 185 | 185 |
| 186 // pow(x,±0) = 1 | 186 // pow(x,±0) = 1 |
| 187 .align ALIGNARG(4) | 187 .align ALIGNARG(4) |
| 188 11: fstp %st(0) // pop y | 188 11: fstp %st(0) // pop y |
| 189 fldl MO(one) | 189 fldl MO(one) |
| 190 » ret | 190 » NACLRET |
| 191 | 191 |
| 192 // y == ±inf | 192 // y == ±inf |
| 193 .align ALIGNARG(4) | 193 .align ALIGNARG(4) |
| 194 12: fstp %st(0) // pop y | 194 12: fstp %st(0) // pop y |
| 195 fldl MO(one) // 1 | 195 fldl MO(one) // 1 |
| 196 flds 4(%esp) // x : 1 | 196 flds 4(%esp) // x : 1 |
| 197 fabs // abs(x) : 1 | 197 fabs // abs(x) : 1 |
| 198 fucompp // < 1, == 1, or > 1 | 198 fucompp // < 1, == 1, or > 1 |
| 199 fnstsw | 199 fnstsw |
| 200 andb $0x45, %ah | 200 andb $0x45, %ah |
| 201 cmpb $0x45, %ah | 201 cmpb $0x45, %ah |
| 202 je 13f // jump if x is NaN | 202 je 13f // jump if x is NaN |
| 203 | 203 |
| 204 cmpb $0x40, %ah | 204 cmpb $0x40, %ah |
| 205 je 14f // jump if |x| == 1 | 205 je 14f // jump if |x| == 1 |
| 206 | 206 |
| 207 shlb $1, %ah | 207 shlb $1, %ah |
| 208 xorb %ah, %dl | 208 xorb %ah, %dl |
| 209 andl $2, %edx | 209 andl $2, %edx |
| 210 fldl MOX(inf_zero, %edx, 4) | 210 fldl MOX(inf_zero, %edx, 4) |
| 211 » ret | 211 » NACLRET |
| 212 | 212 |
| 213 .align ALIGNARG(4) | 213 .align ALIGNARG(4) |
| 214 14: fldl MO(one) | 214 14: fldl MO(one) |
| 215 » ret | 215 » NACLRET |
| 216 | 216 |
| 217 .align ALIGNARG(4) | 217 .align ALIGNARG(4) |
| 218 13: flds 4(%esp) // load x == NaN | 218 13: flds 4(%esp) // load x == NaN |
| 219 » ret | 219 » NACLRET |
| 220 | 220 |
| 221 cfi_adjust_cfa_offset (4) | 221 cfi_adjust_cfa_offset (4) |
| 222 .align ALIGNARG(4) | 222 .align ALIGNARG(4) |
| 223 // x is ±inf | 223 // x is ±inf |
| 224 15: fstp %st(0) // y | 224 15: fstp %st(0) // y |
| 225 testb $2, %dh | 225 testb $2, %dh |
| 226 jz 16f // jump if x == +inf | 226 jz 16f // jump if x == +inf |
| 227 | 227 |
| 228 // We must find out whether y is an odd integer. | 228 // We must find out whether y is an odd integer. |
| 229 fld %st // y : y | 229 fld %st // y : y |
| (...skipping 12 matching lines...) Expand all Loading... |
| 242 jz 18f // jump if not odd | 242 jz 18f // jump if not odd |
| 243 movl %edx, %eax | 243 movl %edx, %eax |
| 244 orl %edx, %edx | 244 orl %edx, %edx |
| 245 jns 155f | 245 jns 155f |
| 246 negl %eax | 246 negl %eax |
| 247 155: cmpl $0x01000000, %eax | 247 155: cmpl $0x01000000, %eax |
| 248 ja 18f // does not fit in mantissa bits | 248 ja 18f // does not fit in mantissa bits |
| 249 // It's an odd integer. | 249 // It's an odd integer. |
| 250 shrl $31, %edx | 250 shrl $31, %edx |
| 251 fldl MOX(minf_mzero, %edx, 8) | 251 fldl MOX(minf_mzero, %edx, 8) |
| 252 » ret | 252 » NACLRET |
| 253 | 253 |
| 254 cfi_adjust_cfa_offset (4) | 254 cfi_adjust_cfa_offset (4) |
| 255 .align ALIGNARG(4) | 255 .align ALIGNARG(4) |
| 256 16: fcompl MO(zero) | 256 16: fcompl MO(zero) |
| 257 addl $4, %esp | 257 addl $4, %esp |
| 258 cfi_adjust_cfa_offset (-4) | 258 cfi_adjust_cfa_offset (-4) |
| 259 fnstsw | 259 fnstsw |
| 260 shrl $5, %eax | 260 shrl $5, %eax |
| 261 andl $8, %eax | 261 andl $8, %eax |
| 262 fldl MOX(inf_zero, %eax, 1) | 262 fldl MOX(inf_zero, %eax, 1) |
| 263 » ret | 263 » NACLRET |
| 264 | 264 |
| 265 cfi_adjust_cfa_offset (4) | 265 cfi_adjust_cfa_offset (4) |
| 266 .align ALIGNARG(4) | 266 .align ALIGNARG(4) |
| 267 17: shll $30, %edx // sign bit for y in right position | 267 17: shll $30, %edx // sign bit for y in right position |
| 268 addl $4, %esp | 268 addl $4, %esp |
| 269 cfi_adjust_cfa_offset (-4) | 269 cfi_adjust_cfa_offset (-4) |
| 270 18: shrl $31, %edx | 270 18: shrl $31, %edx |
| 271 fldl MOX(inf_zero, %edx, 8) | 271 fldl MOX(inf_zero, %edx, 8) |
| 272 » ret | 272 » NACLRET |
| 273 | 273 |
| 274 cfi_adjust_cfa_offset (4) | 274 cfi_adjust_cfa_offset (4) |
| 275 .align ALIGNARG(4) | 275 .align ALIGNARG(4) |
| 276 // x is ±0 | 276 // x is ±0 |
| 277 20: fstp %st(0) // y | 277 20: fstp %st(0) // y |
| 278 testb $2, %dl | 278 testb $2, %dl |
| 279 jz 21f // y > 0 | 279 jz 21f // y > 0 |
| 280 | 280 |
| 281 // x is ±0 and y is < 0. We must find out whether y is an odd integer. | 281 // x is ±0 and y is < 0. We must find out whether y is an odd integer. |
| 282 testb $2, %dh | 282 testb $2, %dh |
| (...skipping 13 matching lines...) Expand all Loading... |
| 296 cfi_adjust_cfa_offset (-4) | 296 cfi_adjust_cfa_offset (-4) |
| 297 testb $1, %dl | 297 testb $1, %dl |
| 298 jz 27f // jump if not odd | 298 jz 27f // jump if not odd |
| 299 cmpl $0xff000000, %edx | 299 cmpl $0xff000000, %edx |
| 300 jbe 27f // does not fit in mantissa bits | 300 jbe 27f // does not fit in mantissa bits |
| 301 // It's an odd integer. | 301 // It's an odd integer. |
| 302 // Raise divide-by-zero exception and get minus infinity value. | 302 // Raise divide-by-zero exception and get minus infinity value. |
| 303 fldl MO(one) | 303 fldl MO(one) |
| 304 fdivl MO(zero) | 304 fdivl MO(zero) |
| 305 fchs | 305 fchs |
| 306 » ret | 306 » NACLRET |
| 307 | 307 |
| 308 cfi_adjust_cfa_offset (4) | 308 cfi_adjust_cfa_offset (4) |
| 309 25: fstp %st(0) | 309 25: fstp %st(0) |
| 310 26: addl $4, %esp | 310 26: addl $4, %esp |
| 311 cfi_adjust_cfa_offset (-4) | 311 cfi_adjust_cfa_offset (-4) |
| 312 27: // Raise divide-by-zero exception and get infinity value. | 312 27: // Raise divide-by-zero exception and get infinity value. |
| 313 fldl MO(one) | 313 fldl MO(one) |
| 314 fdivl MO(zero) | 314 fdivl MO(zero) |
| 315 » ret | 315 » NACLRET |
| 316 | 316 |
| 317 cfi_adjust_cfa_offset (4) | 317 cfi_adjust_cfa_offset (4) |
| 318 .align ALIGNARG(4) | 318 .align ALIGNARG(4) |
| 319 // x is ±0 and y is > 0. We must find out whether y is an odd integer. | 319 // x is ±0 and y is > 0. We must find out whether y is an odd integer. |
| 320 21: testb $2, %dh | 320 21: testb $2, %dh |
| 321 jz 22f | 321 jz 22f |
| 322 | 322 |
| 323 fld %st // y : y | 323 fld %st // y : y |
| 324 fistpl (%esp) // y | 324 fistpl (%esp) // y |
| 325 fildl (%esp) // int(y) : y | 325 fildl (%esp) // int(y) : y |
| 326 fucompp // <empty> | 326 fucompp // <empty> |
| 327 fnstsw | 327 fnstsw |
| 328 sahf | 328 sahf |
| 329 jne 23f | 329 jne 23f |
| 330 | 330 |
| 331 // OK, the value is an integer, but is the number of bits small | 331 // OK, the value is an integer, but is the number of bits small |
| 332 // enough so that all are coming from the mantissa? | 332 // enough so that all are coming from the mantissa? |
| 333 popl %edx | 333 popl %edx |
| 334 cfi_adjust_cfa_offset (-4) | 334 cfi_adjust_cfa_offset (-4) |
| 335 testb $1, %dl | 335 testb $1, %dl |
| 336 jz 24f // jump if not odd | 336 jz 24f // jump if not odd |
| 337 cmpl $0xff000000, %edx | 337 cmpl $0xff000000, %edx |
| 338 jae 24f // does not fit in mantissa bits | 338 jae 24f // does not fit in mantissa bits |
| 339 // It's an odd integer. | 339 // It's an odd integer. |
| 340 fldl MO(mzero) | 340 fldl MO(mzero) |
| 341 » ret | 341 » NACLRET |
| 342 | 342 |
| 343 cfi_adjust_cfa_offset (4) | 343 cfi_adjust_cfa_offset (4) |
| 344 22: fstp %st(0) | 344 22: fstp %st(0) |
| 345 23: addl $4, %esp // Don't use pop. | 345 23: addl $4, %esp // Don't use pop. |
| 346 cfi_adjust_cfa_offset (-4) | 346 cfi_adjust_cfa_offset (-4) |
| 347 24: fldl MO(zero) | 347 24: fldl MO(zero) |
| 348 » ret | 348 » NACLRET |
| 349 | 349 |
| 350 END(__ieee754_powf) | 350 END(__ieee754_powf) |
| OLD | NEW |