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

            Bug ID: 126042
           Summary: -O2 -fno-trapping-math makes worse code than with
                    trapping math for `<=>`
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 54192
  Target Milestone: ---

Take:
```
#include <compare>
bool f5 (double i, double j)
{
    auto c = i <=> j; return c >= 0;
}
```

At -O2 -fno-trapping-math we get in phiopt4:
```
  _6 = i_1(D) > j_2(D);
  _5 = i_1(D) u>= j_2(D);
  _4 = _5 & _6;
```
That is:
```
int f(double i, double j)
{
  int t = i > j;
  int t1 = !__builtin_isless (i,j);
  return t & t1;
}
``
Which is only optimized during reassociation to `i > j`. But really should be
done in match too.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54192
[Bug 54192] -fno-trapping-math by default?

Reply via email to