Bug 114003 - Missing MIN/MAX of extends and known relations of the unextend
Summary: Missing MIN/MAX of extends and known relations of the unextend
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 14.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: VRP
  Show dependency treegraph
 
Reported: 2024-02-19 21:20 UTC by Andrew Pinski
Modified: 2024-02-20 08:12 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2024-02-19 21:20:19 UTC
Take:
```
int f(short a, short b)
{
  if (a > b)
  {
        int aa = a;
        int bb = b;
        bb++;
        int t = aa > bb ? aa : bb;
        return t;
  }
  return 0;
}
```

This should be optimized to just:
```
int f0(short a, short b)
{
  if (a > b)
  {
        return a;
  }
  return 0;
}
```

As if a is equal b+1 (that is the only case where a>b matters), then `extend<a>` and `extend<b>+1` are still equal.