public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wilco at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgcc/108279] Improved speed for float128 routines
Date: Wed, 18 Jan 2023 19:02:19 +0000	[thread overview]
Message-ID: <bug-108279-4-sMth09lJa1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108279-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108279

Wilco <wilco at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wilco at gcc dot gnu.org

--- Comment #18 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Michael_S from comment #12)

> This set of options does not map too well into real difficulties of
> implementation.
> There are only 2 things that are expensive:
> 1. Inexact Exception
> 2. Fetching of the current rounding mode.
> The rest of IEEE-754 features is so cheap that creating separate variants
> without them simply is not worth the effort of maintaining distinct
> variants, even if all difference is a single three-lines #ifdef

In general reading the current rounding mode is relatively cheap, but modifying
can be expensive, so optimized fenv implementations in GLIBC only modify the FP
status if a change is required. It should be feasible to check for
round-to-even and use optimized code for that case.

> BTW, Inexact Exception can be made fairly affordable with a little help from
> compiler. All we need for that is ability to say "don't remove this floating
> point addition even if you don't see that it produces any effect".
> Something similar to 'volatile', but with volatile compiler currently puts
> result of addition on stack, which adds undesirable cost.
> However, judged by comment of Jakub, compiler maintainers are not
> particularly interested in this enterprise.

There are macros in GLIBC math-barriers.h which do what you want - eg. AArch64:

#define math_opt_barrier(x)                                     \
  ({ __typeof (x) __x = (x); __asm ("" : "+w" (__x)); __x; })
#define math_force_eval(x)                                              \
  ({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "w" (__x)); })

The first blocks optimizations (like constant folding) across the barrier, the
2nd forces evaluation of an expression even if it is deemed useless. These are
used in many math functions in GLIBC. They are target specific due to needing
inline assembler operands, but it should be easy to add similar definitions to
libgcc.

  parent reply	other threads:[~2023-01-18 19:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 20:55 [Bug libgcc/108279] New: " tkoenig at gcc dot gnu.org
2023-01-03 21:02 ` [Bug libgcc/108279] " tkoenig at gcc dot gnu.org
2023-01-04 10:43 ` jakub at gcc dot gnu.org
2023-01-04 17:14 ` tkoenig at gcc dot gnu.org
2023-01-04 22:19 ` already5chosen at yahoo dot com
2023-01-11 23:06 ` already5chosen at yahoo dot com
2023-01-12 23:24 ` tkoenig at gcc dot gnu.org
2023-01-13  0:34 ` already5chosen at yahoo dot com
2023-01-13  1:29 ` already5chosen at yahoo dot com
2023-01-14  9:21 ` tkoenig at gcc dot gnu.org
2023-01-14 10:22 ` tkoenig at gcc dot gnu.org
2023-01-14 23:52 ` already5chosen at yahoo dot com
2023-01-15  0:20 ` already5chosen at yahoo dot com
2023-01-15 15:13 ` tkoenig at gcc dot gnu.org
2023-01-15 19:17 ` tkoenig at gcc dot gnu.org
2023-01-15 19:28 ` jakub at gcc dot gnu.org
2023-01-15 22:27 ` already5chosen at yahoo dot com
2023-01-16 22:16 ` joseph at codesourcery dot com
2023-01-18 19:02 ` wilco at gcc dot gnu.org [this message]
2023-01-18 19:20 ` jakub at gcc dot gnu.org
2023-01-18 19:26 ` jakub at gcc dot gnu.org
2023-01-18 20:10 ` wilco at gcc dot gnu.org
2023-01-18 22:28 ` already5chosen at yahoo dot com
2023-01-18 23:31 ` already5chosen at yahoo dot com
2023-02-10 13:38 ` already5chosen at yahoo dot com

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=bug-108279-4-sMth09lJa1@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).