On 10/27/2016 01:27 PM, Bernd Edlinger wrote:
Hi,
by code reading I became aware that libgcc can call count_leading_zeros
in certain cases which can give undefined results. This happens on
signed int128 -> float or double conversions, when the int128 is in the range
INT64_MAX+1 to UINT64_MAX.
Did you actually observe this? Because, prior to this code,
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. */
we have:
/* If there are no high bits set, fall back to one conversion. */
if ((Wtype)u == u)
return (FSTYPE)(Wtype)u;
/* Otherwise, find the power of two. */
Wtype hi = u >> W_TYPE_SIZE;
which looks to me like it ensures that hi is != 0.
Bernd