https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103220
Bug ID: 103220 Summary: missed casting issue with |/&? Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: signed char f(unsigned char a) { unsigned char b = a & 127; signed char c = (signed char) b; signed char d = (signed char) a; signed char e = d & -128; signed char h = c | e; return h; } ---- CUT ---- GCC can optimize this at the RTL level to just return a but misses out at the gimple level. Found this while working on PR 103216.