https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118666
Bug ID: 118666
Summary: Canonicalization of `(a & CST) == CST` and `((~a) &
CST) == 0`
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
Take:
```
int f(int a)
{
return (a & 0x11) == 0x11;
}
int f1(int a)
{
return ((~a) & 0x11) == 0;
}
```
These 2 functions should produce the same code. Right now on aarch64 (and mips)
they produce different code. (x86 produces the same code and do f1). While on
aarch64 f1 would produce better code but on mips f would produce better code.
So once we had canonicalization this there needs some code to chose between the
2 forms. One way is see if we have andn optab and use that. That would solve
aarch64. I am going to do both things.