Hello! On targets where denormals are flushed to zero with -funsafe-math-optimizations (x86 SSE and alpha), it can happen that zero value enters signbit tests in usafe math mode. Since signs of zeroes and NaNs are not preserved in unsafe math mode, gcc.dg/pr28796-2.c can fail on these targets.
We already have a check for non-zero double value in place for unsafe math mode. Attached patch adds additional tests that guarantee that float and long double values are non-zero before signbit tests. 2015-09-29 Uros Bizjak <ubiz...@gmail.com> * gcc.dg/tg-tests.h (foo_1) [UNSAFE]: Also check if f and ld are non-zero for __builtin_signbit tests. Tested on alpha-linux-gnu (where the patch fixes gcc.dg/pr28796-2.c failure) and x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. Index: gcc.dg/tg-tests.h =================================================================== --- gcc.dg/tg-tests.h (revision 228229) +++ gcc.dg/tg-tests.h (working copy) @@ -82,7 +82,7 @@ /* Sign bit of zeros and nans is not preserved in unsafe math mode. */ #ifdef UNSAFE - if (!res_isnan && d != 0) + if (!res_isnan && f != 0 && d != 0 && ld != 0) #endif { if ((__builtin_signbit (f) ? 1 : 0) != res_signbit)