https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109938
Bug ID: 109938
Summary: ((a^c) & b) | a is not opimized to (b & c) | a
Product: gcc
Version: 14.0
Status: UNCONFIRMED
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 f(int a, int b, int c)
{
return ((a^c) & b) | a;
}
int f1(int a, int b, int c)
{
return ((a^c) | a) & (b|a);
}
int f2(int a, int b, int c)
{
return (b & c) | a;
}
```
These 3 functions should produce the same code.
Currently only f1 and f2 produces the decent code.
I noticed this while looking into PR 107887 and it is related to PR 100864.