[Bug libgcc/78067] liggcc2 calls count_leading_zero with 0
bernd.edlinger at hotmail dot de
gcc-bugzilla@gcc.gnu.org
Fri Oct 21 19:46:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78067
--- Comment #2 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
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. */
More information about the Gcc-bugs
mailing list