This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/3] Optimize trunc() and truncf().
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Matt Turner <mattst88 at gmail dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 25 May 2016 10:39:02 +0000
- Subject: Re: [PATCH 1/3] Optimize trunc() and truncf().
- Authentication-results: sourceware.org; auth=none
- References: <1464139950-31943-1-git-send-email-mattst88 at gmail dot com>
On Tue, 24 May 2016, Matt Turner wrote:
> + int64_t exp = (i0 >> 52) & 0x7ff;
> + int64_t mask = UINT64_C(-1) << max(52 - (exp - 1023), 0);
This can involve undefined behavior (shift by more than 63), so ...
> + if (exp < 1023)
> + mask = UINT64_C(0x8000000000000000);
... the shift should only be done at all if exp is large enough.
Likewise for truncf.
--
Joseph S. Myers
joseph@codesourcery.com