From: Bernd Edlinger Date: Thu, 3 Nov 2016 12:52:19 +0000 (+0000) Subject: re PR libgcc/78067 (libgcc2 calls count_leading_zero with 0) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5de3e2d862e02f7b0c8efe8fbec2c15592302ba9;p=gcc.git re PR libgcc/78067 (libgcc2 calls count_leading_zero with 0) 2016-11-03 Bernd Edlinger PR libgcc/78067 * libgcc2.c (__floatdisf, __floatdidf): Avoid undefined results from count_leading_zeros. testsuite: 2016-11-03 Bernd Edlinger PR libgcc/78067 * gcc.dg/torture/fp-int-convert.h: Add more conversion tests. From-SVN: r241817 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 455401fcf4b..5f59bd83962 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-03 Bernd Edlinger + + PR libgcc/78067 + * gcc.dg/torture/fp-int-convert.h: Add more conversion tests. + 2016-11-03 Senthil Kumar Selvaraj * gcc.c-torture/execute/pr78170.c: Require int32plus. diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert.h b/gcc/testsuite/gcc.dg/torture/fp-int-convert.h index 59773e34fa8..bbe96668d0b 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert.h +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert.h @@ -53,6 +53,8 @@ do { \ TEST_I_F_VAL (U, F, HVAL1U (P, U), P_OK (P, U)); \ TEST_I_F_VAL (U, F, HVAL1U (P, U) + 1, P_OK (P, U)); \ TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U)); \ + TEST_I_F_VAL (I, F, WVAL0S (I), 1); \ + TEST_I_F_VAL (I, F, -WVAL0S (I), 1); \ } while (0) #define P_OK(P, T) ((P) >= sizeof(T) * CHAR_BIT) @@ -74,6 +76,7 @@ do { \ ? (S)1 \ : (((S)1 << (sizeof(S) * CHAR_BIT - 2)) \ + ((S)3 << (sizeof(S) * CHAR_BIT - 2 - P)))) +#define WVAL0S(S) (S)((S)1 << (sizeof(S) * CHAR_BIT / 2 - 1)) #define TEST_I_F_VAL(IT, FT, VAL, PREC_OK) \ do { \ diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index e2e5327b37c..e81444c841c 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-03 Bernd Edlinger + + PR libgcc/78067 + * libgcc2.c (__floatdisf, __floatdidf): Avoid undefined results from + count_leading_zeros. + 2016-11-02 Uros Bizjak * Makefile.in (LIB2_DIVMOD_FUNCS): Add _divmoddi4. diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 1d71fc48567..97b9237ea2b 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -1674,6 +1674,11 @@ FUNC (DWtype u) hi = -(UWtype) hi; UWtype count, shift; +#if !defined (COUNT_LEADING_ZEROS_0) || COUNT_LEADING_ZEROS_0 != W_TYPE_SIZE + if (hi == 0) + count = W_TYPE_SIZE; + else +#endif count_leading_zeros (count, hi); /* No leading bits means u == minimum. */