]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libgcc/78067 (libgcc2 calls count_leading_zero with 0)
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Thu, 3 Nov 2016 12:52:19 +0000 (12:52 +0000)
committerBernd Edlinger <edlinger@gcc.gnu.org>
Thu, 3 Nov 2016 12:52:19 +0000 (12:52 +0000)
2016-11-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR libgcc/78067
        * libgcc2.c (__floatdisf, __floatdidf): Avoid undefined results from
        count_leading_zeros.

testsuite:
2016-11-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR libgcc/78067
        * gcc.dg/torture/fp-int-convert.h: Add more conversion tests.

From-SVN: r241817

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/fp-int-convert.h
libgcc/ChangeLog
libgcc/libgcc2.c

index 455401fcf4b63a3e61c2baf08a80347c07db43b1..5f59bd839620a1adb5750e34dd33f4935588ba5d 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR libgcc/78067
+       * gcc.dg/torture/fp-int-convert.h: Add more conversion tests.
+
 2016-11-03  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
        * gcc.c-torture/execute/pr78170.c: Require int32plus.
index 59773e34fa851791b1fc84e4cb444b5684450a14..bbe96668d0bc18e87465160432f2e970a54d0fdc 100644 (file)
@@ -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 {                                                   \
index e2e5327b37cc33e651d0635c488ab2e5ab27d1f0..e81444c841c0ef283e68c4d100bad89ffb2a62c6 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR libgcc/78067
+       * libgcc2.c (__floatdisf, __floatdidf): Avoid undefined results from
+       count_leading_zeros.
+
 2016-11-02  Uros Bizjak  <ubizjak@gmail.com>
 
        * Makefile.in (LIB2_DIVMOD_FUNCS): Add _divmoddi4.
index 1d71fc48567d9bbfe134f1956b754ff4d83a42c3..97b9237ea2b9558d230b9caf209fe088189a9391 100644 (file)
@@ -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.  */