https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121460
Bug ID: 121460 Summary: `switch (v + 20) case` should optimize away the addition Product: gcc Version: 16.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void foo (int, int); __attribute__((noinline, noclone)) void f1 (unsigned char v, int w) { unsigned char i, j; switch (v + 20) { case 170: j = 7; i = w; break; case 171: i = 8; j = v; break; case 172: i = 21; j = -19; break; case 173: i = 18; j = -w; break; case 174: i = 33; j = 55; break; case 175: i = 33; j = w; break; case 176: i = 33; j = 55; break; case 177: i = w; j = 55; break; default: __builtin_abort (); } lab: foo (i, j); } ``` GCC should optimize away the addition.