From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: "michael.hudson@canonical.com" <michael.hudson@canonical.com>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: [PATCH] Ensure calculations happen with desired rounding mode in y1lf128
Date: Fri, 12 Aug 2022 12:28:42 +0000 [thread overview]
Message-ID: <AM5PR0801MB16686F7E4FC42758D0C6930E83679@AM5PR0801MB1668.eurprd08.prod.outlook.com> (raw)
Hi Michael,
> I don't know if this patch should be committed as is, although it does
> fix an observed failure for me.
The patch looks good to me, but this is a more general issue...
> My read of the discussion in the gcc bug I filed about this
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106574 is that every single
> use of a SET_RESTORE_ROUND macro is vulnerable to this. I can't think of
> a generic way to fix this -- I guess you could have a macro to call an
> always_inline function with a rounding mode set? But that would uglify
> the control flow in the code quite a bit.
Indeed, there is no general way to block optimizations across a boundary in
GCC if they do not involve memory accesses. As a result it is never safe to
change the rounding mode inside a function...
All math functions using the SET_RESTORE_ROUND macros will need similar
barriers. Note that it is feasible to remove these macros altogether and fix
any issues (a slightly larger ULP is acceptable for non-nearest rounding).
Given rounding mode changes are generally expensive, this also improves
performance (though that may not be important for 128-bit floats).
Cheers,
Wilco
next reply other threads:[~2022-08-12 12:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 12:28 Wilco Dijkstra [this message]
2022-08-15 20:59 ` Joseph Myers
2022-08-17 4:23 ` Michael Hudson-Doyle
2022-08-17 11:53 ` Wilco Dijkstra
2022-08-17 16:52 ` Joseph Myers
2022-08-22 12:28 ` Paul Zimmermann
-- strict thread matches above, loose matches on Subject: below --
2022-08-12 0:05 Michael Hudson-Doyle
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=AM5PR0801MB16686F7E4FC42758D0C6930E83679@AM5PR0801MB1668.eurprd08.prod.outlook.com \
--to=wilco.dijkstra@arm.com \
--cc=libc-alpha@sourceware.org \
--cc=michael.hudson@canonical.com \
/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).