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

            Bug ID: 126075
           Summary: missing frange related optimization with bit_and for
                    the comparison vs different if statements
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 85316
  Target Milestone: ---

Take:
```
void
baz (_Float64 x)
{
  _Float128 w = x;
  if (w >= -64.0f128 && w <= 0x1.p+1026f128)
    {
      if (__builtin_isnan (x)
          || __builtin_isinf (x)
          || x < -64.0f64)
        link_failure ();
    }
}

void
baz1 (_Float64 x)
{
  _Float128 w = x;
  int t = w >= -64.0f128;
  int t1 = w <= 0x1.p+1026f128;
  if ((t != 0) & (t1 != 0))
    {
      if (__builtin_isnan (x)
          || __builtin_isinf (x)
          || x < -64.0f64)
        link_failure ();
    }
}
```

I had assumed baz1 would have been optimized in a similar fashion as baz is at
-O2. But it looks like we don't.

This shows up when testing -fno-trapping-math but it can be reproduced
independently as shown above.
This is reduced from pr120231-1.c.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

Reply via email to