On Fri, Jul 22, 2016 at 09:59:33PM +0000, Joseph Myers wrote: > Index: gcc/testsuite/gcc.dg/torture/fp-int-convert-float16-timode.c > =================================================================== > --- gcc/testsuite/gcc.dg/torture/fp-int-convert-float16-timode.c > (nonexistent) > +++ gcc/testsuite/gcc.dg/torture/fp-int-convert-float16-timode.c > (working copy) > @@ -0,0 +1,15 @@ > +/* Test floating-point conversions. _Float16 type with TImode. */ > +/* { dg-do run } */ > +/* { dg-require-effective-target float16 } */ > +/* { dg-options "" } */ > + > +#define __STDC_WANT_IEC_60559_TYPES_EXT__ > +#include <float.h> > +#include "fp-int-convert.h" > + > +int > +main (void) > +{ > + TEST_I_F(TItype, UTItype, _Float16, FLT16_MANT_DIG); > + exit (0); > +} > Index: gcc/testsuite/gcc.dg/torture/fp-int-convert-float16.c > =================================================================== > --- gcc/testsuite/gcc.dg/torture/fp-int-convert-float16.c (nonexistent) > +++ gcc/testsuite/gcc.dg/torture/fp-int-convert-float16.c (working copy) > @@ -0,0 +1,19 @@ > +/* Test floating-point conversions. Standard types and _Float16. */ > +/* { dg-do run } */ > +/* { dg-require-effective-target float16 } */ > +/* { dg-options "" } */ > + > +#define __STDC_WANT_IEC_60559_TYPES_EXT__ > +#include <float.h> > +#include "fp-int-convert.h" > + > +int > +main (void) > +{ > + TEST_I_F(signed char, unsigned char, _Float16, FLT16_MANT_DIG); > + TEST_I_F(signed short, unsigned short, _Float16, FLT16_MANT_DIG); > + TEST_I_F(signed int, unsigned int, _Float16, FLT16_MANT_DIG); > + TEST_I_F(signed long, unsigned long, _Float16, FLT16_MANT_DIG); > + TEST_I_F(signed long long, unsigned long long, _Float16, FLT16_MANT_DIG); > + exit (0); > +}
Hi Joseph, These tests will fail for _Float16 implementations. One of the tests in fp-int-convert.h tries to convert to and from 0x8..0 in the width of the unsigned integer mode. But 0x8..0 is not representable in a 16-bit float for any of unsigned int, unsigned long, unsigned long long, or UTItype so the check that conversion to and from 16-bit float returns the input value will fail. The relevant line in testsuite/gcc.dg/torture/fp-int-convert.h is: TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1); The reduced, preprocessed test below should show the issue I am referring to clearly: extern void abort(void); extern void exit(int); typedef int int128_t __attribute__((mode(TI))); typedef unsigned int uint128_t __attribute__((mode(TI))); int main (int argc, char** argv) { static volatile uint128_t ivin, ivout; static volatile _Float16 fv1, fv2; ivin = ~((~(uint128_t)0) >> 1); fv1 = ~((~(uint128_t)0) >> 1); fv2 = ivin; ivout = fv2; if (ivout != ivin) abort (); } This test will always abort for a _Float16 implementation. The obvious fix would be this modification to fp-int-convert.h: - TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1); \ + TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), P_OK1 (P, U)); \ Thanks, James