https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115082
Bug ID: 115082
Summary: Canonical form for `(a+oddCST)&1` or `1 & ~a`
Product: gcc
Version: 15.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: ---
This is more of Canonical form issue rather than a missed optimization.
Take:
```
int g1(int a,int c)
{
int b = 1 + c;
return b & 1;
}
int g2(int a,int c)
{
int b = 1 & ~c;
return b & 1;
}
```
These 2 functions are equivalent but current produce different assembly.
For gimple the first form is definitely preferable due to having 2 statements
rather than 3. And for targets which don't have andnot instructions, the first
might be better too.
(note g2 does not produce the andnot instruction on aarch64 though which I file
seperately)