This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcc/78067] liggcc2 calls count_leading_zero with 0


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.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]