https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118650
Bug ID: 118650
Summary: `(even + unknown) & 1` is not optimized to just
`unknown & 1` at gimple level
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
int f(int a, int d)
{
int b = a * 2;
b = b + d;
return b & 1;
}
```
This should optimize down to just `d & 1` since we know that (a*2) will not
cause the lower bits to be set.
The generic case is:
(a + b) & CST -> `b & CST` iff `a&CST` is known to be 0.