https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122845
Bug ID: 122845
Summary: `a ^ CST ^ CST` is sometimes not folded at the gimple
level (casts)
Product: gcc
Version: 16.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:
```
struct s1
{
signed f1:3;
};
struct s1 p;
void f(void)
{
p.f1 ^= -47;
p.f1 ^= -47;
}
```
This should be simplified into a nop but currently it is not done on the gimple
level due to casts.
We get:
```
_1 = p.f1;
_2 = (signed char) _1;
_3 = _2 ^ -47;
_4 = (<unnamed-signed:3>) _3;
_5 = (signed char) _4;
_6 = _5 ^ -47;
_7 = (<unnamed-signed:3>) _6;
p.f1 = _7;
```
This is a side issue reduced from PR 122843.