aboutsummaryrefslogtreecommitdiff
path: root/math/auto-libm-test-out-pow
AgeCommit message (Collapse)Author
2018-12-11Fix powf overflow handling in non-nearest rounding mode [BZ #23961]Szabolcs Nagy
The threshold value at which powf overflows depends on the rounding mode and the current check did not take this into account. So when the result was rounded away from zero it could become infinity without setting errno to ERANGE. Example: pow(0x1.7ac7cp+5, 23) is 0x1.fffffep+127 + 0.1633ulp If the result goes above 0x1.fffffep+127 + 0.5ulp then errno is set, which is fine in nearest rounding mode, but powf(0x1.7ac7cp+5, 23) is inf in upward rounding mode powf(-0x1.7ac7cp+5, 23) is -inf in downward rounding mode and the previous implementation did not set errno in these cases. The fix tries to avoid affecting the common code path or calling a function that may introduce a stack frame, so float arithmetics is used to check the rounding mode and the threshold is selected accordingly. [BZ #23961] * math/auto-libm-test-in: Add new test case. * math/auto-libm-test-out-pow: Regenerated. * sysdeps/ieee754/flt-32/e_powf.c (__powf): Fix overflow check.
2017-02-07Fix powf inaccuracy (bug 21112).Joseph Myers
Bug 21112 reports a case where powf is substantially inaccurate. This results from a multiplication where cp_h*p_h is required to be exact, and p_h is masked to have only 12 leading nonzero bits in its mantissa, but the value of cp_h has the 13th bit nonzero, leading to inexact multiplication results in some cases that can result in large errors in the final result of powf. This patch fixes this by using a value of cp_h correctly rounded to nearest to 12 bits, with a corresponding updated value of cp_l. Tested for x86_64 and x86. [BZ #21112] * sysdeps/ieee754/flt-32/e_powf.c (cp_h): Use value with trailing 12 bits zero. (cp_l): Update for new value of cp_h. * math/auto-libm-test-in: Add another test of pow. * math/auto-libm-test-out-pow: Regenerated.
2017-02-06Split auto-libm-test-out by function.Joseph Myers
math/auto-libm-test-out is, at over 30 MB, by far the largest file in the glibc source tree. This patch splits it by function, so reducing it to auto-libm-test-out-<func> files that are all under 5 MB in size. This is preliminary to splitting up libm-test.inc as well so that each function's tests can also be processed separately by gen-libm-test.pl. As a preliminary patch it doesn't actually implement that step; rather, all the separate files get concatenated by the Makefile to produce the monolithic auto-libm-test-out file again as an input to gen-libm-test.pl. (The concatentation is identical to the file in the source tree before this patch.) Even this preliminary step, however, is of use independent of splitting up libm-test.inc: some tests for csin and csinh have not been moved to auto-libm-test-in because they result in auto-libm-test-out generation taking several minutes rather than a few seconds (all released MPC versions are very slow for certain sin / sinh inputs; there are some old improvements in MPC mainline which should eventually become MPC 1.1, but the complex inverse trig and hyperbolic functions are slow even in MPC mainline and have yet to be moved to auto-libm-test-in at all), and it seems much more reasonable to add such inputs to auto-libm-test-in when it will only slow down regeneration for particular functions than when it will slow down regeneration globally. gen-auto-libm-tests still parses the whole input file, but only generates output for the requested function. This ensures bad syntax in the file is always detected, and parsing the whole file is quick; it's output generation that is comparatively slow for some functions. Tested for x86_64. * math/gen-auto-libm-tests.c: Update comment about use of program. (generate_output): Add argument FUNCTION. (main): Require extra argument. Pass function name to generate_output. * math/Makefile (generated): Add auto-libm-test-out. (libm-test-funcs-auto): New variable. (auto-libm-test-out-files): New variable. ($(objpfx)libm-test.c): Depend on $(auto-libm-test-out-files). Concatenate those files to form $(objpfx)auto-libm-test-out and use it as input to gen-libm-test.pl. * math/README.libm-test: Update. * math/auto-libm-test-out: Remove. * math/auto-libm-test-out-acos: New generated file. * math/auto-libm-test-out-acosh: Likewise. * math/auto-libm-test-out-asin: Likewise. * math/auto-libm-test-out-asinh: Likewise. * math/auto-libm-test-out-atan: Likewise. * math/auto-libm-test-out-atan2: Likewise. * math/auto-libm-test-out-atanh: Likewise. * math/auto-libm-test-out-cabs: Likewise. * math/auto-libm-test-out-carg: Likewise. * math/auto-libm-test-out-cbrt: Likewise. * math/auto-libm-test-out-ccos: Likewise. * math/auto-libm-test-out-ccosh: Likewise. * math/auto-libm-test-out-cexp: Likewise. * math/auto-libm-test-out-clog: Likewise. * math/auto-libm-test-out-clog10: Likewise. * math/auto-libm-test-out-cos: Likewise. * math/auto-libm-test-out-cosh: Likewise. * math/auto-libm-test-out-cpow: Likewise. * math/auto-libm-test-out-csin: Likewise. * math/auto-libm-test-out-csinh: Likewise. * math/auto-libm-test-out-csqrt: Likewise. * math/auto-libm-test-out-ctan: Likewise. * math/auto-libm-test-out-ctanh: Likewise. * math/auto-libm-test-out-erf: Likewise. * math/auto-libm-test-out-erfc: Likewise. * math/auto-libm-test-out-exp: Likewise. * math/auto-libm-test-out-exp10: Likewise. * math/auto-libm-test-out-exp2: Likewise. * math/auto-libm-test-out-expm1: Likewise. * math/auto-libm-test-out-fma: Likewise. * math/auto-libm-test-out-hypot: Likewise. * math/auto-libm-test-out-j0: Likewise. * math/auto-libm-test-out-j1: Likewise. * math/auto-libm-test-out-jn: Likewise. * math/auto-libm-test-out-lgamma: Likewise. * math/auto-libm-test-out-log: Likewise. * math/auto-libm-test-out-log10: Likewise. * math/auto-libm-test-out-log1p: Likewise. * math/auto-libm-test-out-log2: Likewise. * math/auto-libm-test-out-pow: Likewise. * math/auto-libm-test-out-sin: Likewise. * math/auto-libm-test-out-sincos: Likewise. * math/auto-libm-test-out-sinh: Likewise. * math/auto-libm-test-out-sqrt: Likewise. * math/auto-libm-test-out-tan: Likewise. * math/auto-libm-test-out-tanh: Likewise. * math/auto-libm-test-out-tgamma: Likewise. * math/auto-libm-test-out-y0: Likewise. * math/auto-libm-test-out-y1: Likewise. * math/auto-libm-test-out-yn: Likewise.