https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128521
Bug ID: 128521
Summary: `x ord x` can be treated as `x ord CST` when combining
with `x CMP CST`
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: easyhack, missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
int f(double x)
{
int t = !__builtin_isunordered(x, x);
int t1 = x > 1.0;
return t1 & t;
}
int f1(double x, double y)
{
int t = !__builtin_isunordered(x, 1.0);
int t1 = x > 1.0;
return t1 & t;
}
```
For non-trapping (though the trapping case is different and I am too lazy to
figure out a testcase for it), these 2 should produce the same code but does
not currently as we don't treat `x ord x` as the same as `x ord CST` and don't
combine the two. The same is true of unord.