https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103216
Bug ID: 103216 Summary: missed optimization, phiopt/vrp? Product: gcc Version: 12.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: --- signed char f(unsigned char a) { unsigned char b; signed char c, d, v; b = a & 127; c = (signed char) b; d = (signed char) a; v = c; if (d < 0) v = c | -128; return v; } This should just be optimized to return (signed char)a; Reduced from the testcase provided by https://twitter.com/__phantomderp/status/1459247957904080901 .