[Bug libgcc/78067] liggcc2 calls count_leading_zero with 0

2016-11-03 Thread bernd.edlinger at hotmail dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78067

Bernd Edlinger  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Bernd Edlinger  ---
fixed.

[Bug libgcc/78067] liggcc2 calls count_leading_zero with 0

2016-11-03 Thread edlinger at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78067

--- Comment #3 from Bernd Edlinger  ---
Author: edlinger
Date: Thu Nov  3 12:52:19 2016
New Revision: 241817

URL: https://gcc.gnu.org/viewcvs?rev=241817=gcc=rev
Log:
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.

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

[Bug libgcc/78067] liggcc2 calls count_leading_zero with 0

2016-10-21 Thread bernd.edlinger at hotmail dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78067

--- Comment #2 from Bernd Edlinger  ---
This happens with __floattisf and __floattidf in 64bit libgcc.

But because a bsr $rsi,$rsi is used, apparently the result register is zero,
when the input is zero and not completely undefined.  Thus __floattisf/df
seems to return correct results although the count is 63 instead of 64.
That seems to be just luck, if other registers would be used, the function
would fail.

Possible patch:

Index: libgcc2.c
===
--- libgcc2.c   (revision 241400)
+++ libgcc2.c   (working copy)
@@ -1643,6 +1643,11 @@
 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.  */

[Bug libgcc/78067] liggcc2 calls count_leading_zero with 0

2016-10-21 Thread bernd.edlinger at hotmail dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78067

--- Comment #1 from Bernd Edlinger  ---
I think in the case of x86 longlong.h
does not define COUNT_LEADING_ZEROS_0
but nevertheless count_leading_zero
is defined to __builtin_clz and
seems to return the correct result,
but I don't know if that will always be the
case, or why longlong.h does not define
COUNT_LEADING_ZEROS_0 to 64.