From: Corinna Vinschen <vinschen@redhat.com>
To: newlib@sourceware.org
Subject: Re: [PATCH 1/2] Avoid implicit floating point conversions [v2]
Date: Mon, 24 Aug 2020 11:58:21 +0200 [thread overview]
Message-ID: <20200824095821.GA3272@calimero.vinschen.de> (raw)
In-Reply-To: <20200821003539.942952-2-keithp@keithp.com>
On Aug 20 17:35, Keith Packard via Newlib wrote:
> These were found with clang -Wdouble-promotion and show places where
> floating point values were being implicitly converted between
> representations. These conversions can result in unexpected use of
> double precision arithmetic. Those which are intentional all have an
> explicit cast added.
> [...]
> diff --git a/newlib/libm/common/exp.c b/newlib/libm/common/exp.c
> index 12c08c992..f3e95c6f5 100644
> --- a/newlib/libm/common/exp.c
> +++ b/newlib/libm/common/exp.c
> @@ -114,9 +114,9 @@ exp (double x)
> return WANT_ROUNDING ? 1.0 + x : 1.0;
> if (abstop >= top12 (1024.0))
> {
> - if (asuint64 (x) == asuint64 (-INFINITY))
> + if (asuint64 (x) == asuint64 ((double) -INFINITY))
> return 0.0;
> - if (abstop >= top12 (INFINITY))
> + if (abstop >= top12 ((double) INFINITY))
Not taking implicit compiler optimisations into account, wouldn't it
make more sense to avoid the conversion altogether, using
__builtin_inf() in these places?
Thanks,
Corinna
next prev parent reply other threads:[~2020-08-24 9:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 0:35 [PATCH 0/2] Floating point conversion warning fixes [v2] Keith Packard
2020-08-21 0:35 ` [PATCH 1/2] Avoid implicit floating point conversions [v2] Keith Packard
2020-08-24 9:58 ` Corinna Vinschen [this message]
2020-08-24 15:33 ` Keith Packard
2020-08-25 11:10 ` Corinna Vinschen
2020-08-25 13:37 ` Thomas Wucher
2020-08-21 0:35 ` [PATCH 2/2] libm/common: Remove unused 'dec' function from sqrtl.c Keith Packard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200824095821.GA3272@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).