ARM: fp16 Fix PR 67624 - Incorrect conversion of float Infinity to __fp16

PR libgcc/67624
	libgcc:
	* config/arm/fp16.c (__gnu_f2h_internal): Handle infinity correctly.
	gcc/testsuite:
	* gcc.target/arm/fp16-inf.c: New test.

From-SVN: r228082
This commit is contained in:
Richard Earnshaw 2015-09-24 09:40:06 +00:00 committed by Richard Earnshaw
parent 60dd79ca89
commit 4dfe21acc2
4 changed files with 29 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2015-09-24 Richard Earnshaw <rearnsha@arm.com>
PR libgcc/67624
* gcc.target/arm/fp16-inf.c: New test.
2015-09-24 Kirill Yukhin <kirill.yukhin@intel.com>
* gcc.target/i386/avx512vbmi-check.h (main): Fix register

View File

@ -0,0 +1,14 @@
/* { dg-do run } */
/* { dg-options "-O -mfp16-format=ieee" } */
/* Conversion of infinity to __fp16 and back again should preserve the
value. */
volatile float f = __builtin_inf ();
int main ()
{
__fp16 h = f;
if (h != __builtin_inf ())
__builtin_abort ();
return 0;
}

View File

@ -1,3 +1,8 @@
2015-09-24 Richard Earnshaw <rearnsha@arm.com>
PR libgcc/67624
* config/arm/fp16.c (__gnu_f2h_internal): Handle infinity correctly.
2015-09-24 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* config.host (*-*-solaris2*): Add t-crtstuff-pic to tmake_file.

View File

@ -35,9 +35,12 @@ __gnu_f2h_internal(unsigned int a, int ieee)
{
if (!ieee)
return sign;
if (mantissa == 0)
return sign | 0x7c00; /* Infinity. */
/* Remaining cases are NaNs. Convert SNaN to QNaN. */
return sign | 0x7e00 | (mantissa >> 13);
}
if (aexp == 0 && mantissa == 0)
return sign;
@ -49,7 +52,7 @@ __gnu_f2h_internal(unsigned int a, int ieee)
{
mask = 0x00ffffff;
if (aexp >= -25)
mask >>= 25 + aexp;
mask >>= 25 + aexp;
}
else
mask = 0x00001fff;