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

            Bug ID: 126092
           Summary: `if (a >= 3) if (b >= 3)` seems not to back prop to
                    min for vrp
           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 use(void);

__attribute__((always_inline))
inline int min(int a, int b)
{
  return a < b ? a : b;
}
__attribute__((always_inline))
inline int max(int a, int b)
{
  return a > b ? a : b;
}

void f(int a, int b) {
    int m = min(a,b);
    if (a >= 3)
        if (b >= 3)
          {
            if (m < 3) use();  // dead
          }
}


void f1(int a, int b) {
    int m = max(a,b);
    if (a < 31)
        if (b < 31)
          {
            if (m > 31) use();  // dead
          }
}
```

Evrp is not able to optimize away `m < 3` here. Basically once a and b have a
min part of their range defined then m has one too.

Max has the same issue, see f1.

I am not sure if this is doable though.


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