https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126227
Bug ID: 126227
Summary: `(inta > int b) - (inta < intb)` should be recongized
as a shipship operator
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
Target Milestone: ---
Take:
```
int cmp_int_asc(int a, int b) {
return (a < b) ? -1 : (a > b ? 1 : 0);
}
int cmp_int_asc_2(int a, int b) {
return (a < b) ? -1 : (a > b ? 1 : 0);
}
int cmp_int_asc_branchless(int a, int b) {
return (a > b) - (a < b);
}
```
cmp_int_asc and cmp_int_asc_2 is reconigzed as a shipship operator but
cmp_int_asc_branchless is not.
Note `(a < b) - (a > b)` is a shapeship operator with lhs and rhs swapped.