diff mbox

[testsuite] : Check all variables to be non-zero before signbit tests in tg-tests.h

Message ID CAFULd4b3Q-8bFyv7ZPb+2fh-h6nM5dTsak_w5RtG9WUWyivqnQ@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Sept. 29, 2015, 11:31 a.m. UTC
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  <ubizjak@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.
diff mbox

Patch

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)