diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-03-21 12:14:57 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2012-03-21 12:16:00 +0000 |
commit | 2460d3aa21f04cdf28497683bd3e29183189f779 (patch) | |
tree | d01d4f4002b56099e0f8959e39aa5eee7dc1db10 /sysdeps/i386/fpu/e_powf.S | |
parent | eb96ffb07d0b1b23ecfaf9520d6757c7dbea0bd1 (diff) | |
download | glibc-2460d3aa21f04cdf28497683bd3e29183189f779.tar glibc-2460d3aa21f04cdf28497683bd3e29183189f779.tar.gz glibc-2460d3aa21f04cdf28497683bd3e29183189f779.tar.bz2 glibc-2460d3aa21f04cdf28497683bd3e29183189f779.zip |
Fix pow of zero and infinity to large powers.
Diffstat (limited to 'sysdeps/i386/fpu/e_powf.S')
-rw-r--r-- | sysdeps/i386/fpu/e_powf.S | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/sysdeps/i386/fpu/e_powf.S b/sysdeps/i386/fpu/e_powf.S index cc8456d280..aa58ed2b67 100644 --- a/sysdeps/i386/fpu/e_powf.S +++ b/sysdeps/i386/fpu/e_powf.S @@ -224,6 +224,16 @@ ENTRY(__ieee754_powf) testb $2, %dh jz 16f // jump if x == +inf + // fistpl raises invalid exception for |y| >= 1L<<31, so test + // that (in which case y is certainly even) before testing + // whether y is odd. + fld %st // y : y + fabs // |y| : y + fcompl MO(p31) // y + fnstsw + sahf + jnc 16f + // We must find out whether y is an odd integer. fld %st // y : y fistpl (%esp) // y @@ -233,18 +243,11 @@ ENTRY(__ieee754_powf) sahf jne 17f - // OK, the value is an integer, but is the number of bits small - // enough so that all are coming from the mantissa? + // OK, the value is an integer. popl %edx cfi_adjust_cfa_offset (-4) testb $1, %dl jz 18f // jump if not odd - movl %edx, %eax - orl %edx, %edx - jns 155f - negl %eax -155: cmpl $0x01000000, %eax - ja 18f // does not fit in mantissa bits // It's an odd integer. shrl $31, %edx fldl MOX(minf_mzero, %edx, 8) @@ -281,6 +284,16 @@ ENTRY(__ieee754_powf) testb $2, %dh jz 25f + // fistpl raises invalid exception for |y| >= 1L<<31, so test + // that (in which case y is certainly even) before testing + // whether y is odd. + fld %st // y : y + fabs // |y| : y + fcompl MO(p31) // y + fnstsw + sahf + jnc 25f + fld %st // y : y fistpl (%esp) // y fildl (%esp) // int(y) : y @@ -289,14 +302,11 @@ ENTRY(__ieee754_powf) sahf jne 26f - // OK, the value is an integer, but is the number of bits small - // enough so that all are coming from the mantissa? + // OK, the value is an integer. popl %edx cfi_adjust_cfa_offset (-4) testb $1, %dl jz 27f // jump if not odd - cmpl $0xff000000, %edx - jbe 27f // does not fit in mantissa bits // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. fldl MO(one) @@ -319,6 +329,14 @@ ENTRY(__ieee754_powf) 21: testb $2, %dh jz 22f + // fistpl raises invalid exception for |y| >= 1L<<31, so test + // that (in which case y is certainly even) before testing + // whether y is odd. + fcoml MO(p31) // y + fnstsw + sahf + jnc 22f + fld %st // y : y fistpl (%esp) // y fildl (%esp) // int(y) : y @@ -327,14 +345,11 @@ ENTRY(__ieee754_powf) sahf jne 23f - // OK, the value is an integer, but is the number of bits small - // enough so that all are coming from the mantissa? + // OK, the value is an integer. popl %edx cfi_adjust_cfa_offset (-4) testb $1, %dl jz 24f // jump if not odd - cmpl $0xff000000, %edx - jae 24f // does not fit in mantissa bits // It's an odd integer. fldl MO(mzero) ret |