* tests/test-ceilf2.c (ceilf_reference): Avoid icc's use of DAZ [denormals-as-zero] when optimizing without -mieee-fp option. * tests/test-floorf2.c (floorf_reference): Likewise.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- This fixes failures of icc without -mieee-fp on test-{ceil,floor}f2.c. However, it does not fix test-{ceil,floor}f1.c, where my recent testsuite improvements flushed out the following compiler quirk: icc -mieee-fp, as well as icc -O0 (which is also implied by icc -g), emit a call to ceilf(); therefore, if -lm has a working implementation, then configure detects that it is working, lib/ceil.c is never compiled, and the test passes. But icc -O2 (which is the default with plain icc) recognizes ceilf and inlines it into assembly code that unfortunately turns -0.0f into 0.0. Technically, this is not a bug, since POSIX is explicit that compliance of -0.0f is an optional feature, if you are not compliant with the <MX> option. And, since I'm still not sure I want to force -mieee-fp onto all gnulib projects, that means I'm still scratching my head for a way to either defeat icc's insistence on inlining ceilf, or I'll have to tighten m4/ceilf.m4 to detect when icc is being used without full IEEE compliance. ChangeLog | 5 +++++ tests/test-ceilf2.c | 3 +++ tests/test-floorf2.c | 3 +++ 3 files changed, 11 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index cce182c..b853aad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-11-05 Eric Blake <ebl...@redhat.com> + ceil, floor: avoid spurious failure with icc + * tests/test-ceilf2.c (ceilf_reference): Avoid icc's use of DAZ + [denormals-as-zero] when optimizing without -mieee-fp option. + * tests/test-floorf2.c (floorf_reference): Likewise. + tests: require working signbit * modules/ceilf-tests (Depends-on): Add signbit. * modules/ceill-tests (Depends-on): Likewise. diff --git a/tests/test-ceilf2.c b/tests/test-ceilf2.c index 705c19a..3455cbf 100644 --- a/tests/test-ceilf2.c +++ b/tests/test-ceilf2.c @@ -63,6 +63,9 @@ ceilf_reference (DOUBLE x) if (z > L_(0.0)) { + /* Work around ICC's desire to optimize denormal floats to 0. */ + if (z < FLT_MIN) + return L_(1.0); /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */ if (z < TWO_MANT_DIG) { diff --git a/tests/test-floorf2.c b/tests/test-floorf2.c index b26a508..6811728 100644 --- a/tests/test-floorf2.c +++ b/tests/test-floorf2.c @@ -76,6 +76,9 @@ floorf_reference (DOUBLE x) } else if (z < L_(0.0)) { + /* Work around ICC's desire to optimize denormal floats to 0. */ + if (z > -FLT_MIN) + return L_(-1.0); /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1. */ if (z > - TWO_MANT_DIG) { -- 1.7.3.2