public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/114131] New: std::isinf(std::float128_t) generates superfluous nan-checks
@ 2024-02-27 14:18 g.peterhoff@t-online.de
  2024-02-27 14:23 ` [Bug libgcc/114131] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: g.peterhoff@t-online.de @ 2024-02-27 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114131
           Summary: std::isinf(std::float128_t) generates superfluous
                    nan-checks
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: g.peterhoff@t-online.de
  Target Milestone: ---

please see https://godbolt.org/z/djc9q1vcv
test1(default): includes nan-checks (__unordtf2)
test2: no nan-checks, but calls __eqtf2
test3: only checks for inf (via bit_cast); no additional function calls +
branchfree. Of course, this only works if (unsigned) __int128 is available.

thx
Gero

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libgcc/114131] std::isinf(std::float128_t) generates superfluous nan-checks
  2024-02-27 14:18 [Bug libgcc/114131] New: std::isinf(std::float128_t) generates superfluous nan-checks g.peterhoff@t-online.de
@ 2024-02-27 14:23 ` redi at gcc dot gnu.org
  2024-02-27 19:44 ` [Bug middle-end/114131] " pinskia at gcc dot gnu.org
  2024-02-27 19:48 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-27 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-02-27
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |missed-optimization

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/114131] std::isinf(std::float128_t) generates superfluous nan-checks
  2024-02-27 14:18 [Bug libgcc/114131] New: std::isinf(std::float128_t) generates superfluous nan-checks g.peterhoff@t-online.de
  2024-02-27 14:23 ` [Bug libgcc/114131] " redi at gcc dot gnu.org
@ 2024-02-27 19:44 ` pinskia at gcc dot gnu.org
  2024-02-27 19:48 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-27 19:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am almost positive this is due to GCC default of trapping math here.

Adding  -fno-trapping-math GCC no longer has a check against NaN.

I think test2 can cause an fp exception to happen so it is almost definitely
not valid transformation unless with -fno-trapping-math.

As far as transforming test1 to test3, well it depends on if there are no
instructions to do the comparison and you are doing "soft" float for that type.
Basically we have:
```
  _1 = ABS_EXPR <x_3(D)>;
  _2 = _1 u<= 1.18973149535723176508575932662800701619646905264169404553e+4932;
  _4 = ~_2;
```

Which we could recognize in the middle-end to do the transformation if the FP
format is easy to handle (double double is one which is not).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/114131] std::isinf(std::float128_t) generates superfluous nan-checks
  2024-02-27 14:18 [Bug libgcc/114131] New: std::isinf(std::float128_t) generates superfluous nan-checks g.peterhoff@t-online.de
  2024-02-27 14:23 ` [Bug libgcc/114131] " redi at gcc dot gnu.org
  2024-02-27 19:44 ` [Bug middle-end/114131] " pinskia at gcc dot gnu.org
@ 2024-02-27 19:48 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-27 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually this is a fully a dup of bug 94083.

*** This bug has been marked as a duplicate of bug 94083 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-27 19:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 14:18 [Bug libgcc/114131] New: std::isinf(std::float128_t) generates superfluous nan-checks g.peterhoff@t-online.de
2024-02-27 14:23 ` [Bug libgcc/114131] " redi at gcc dot gnu.org
2024-02-27 19:44 ` [Bug middle-end/114131] " pinskia at gcc dot gnu.org
2024-02-27 19:48 ` pinskia at gcc dot gnu.org

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).