https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107881
Bug ID: 107881
Summary: (a <= b) == (b >= a) should be optimized to (a == b)
Product: gcc
Version: 13.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: 107880
Target Milestone: ---
Take:
```
bool f(int a, int b)
{
bool t = b <= a;
bool t1 = a <= b;
return t == t1;
}
```
We should optimize this to just:
```
bool f1(int a, int b)
{
return a == b;
}
```
LLVM is able to do it.
We can optimize for & and | but not ^ or ==. (note != gets changed into ^)
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880
[Bug 107880] bool tautology missed optimisation