https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102121
Bug ID: 102121 Summary: switch conversion to load table should do integer compression 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: --- Take: int f(int a) { switch (a) { case 0: return 100; case 1: return 200; case 3: return 250; case 4: return 0; case 5: return 7; case 6: return 3; } return 0; } int f1(int a) { unsigned char t = 0; switch (a) { case 0: t=100; break; case 1: t = 200u; break; case 3: t = 250u; break; case 4: t = 0; break; case 5: t = 7; break; case 6: t = 3; break; } asm("":"+r"(t)); return t; } These two functions should have the same assembly and the load table should be using byte loads for both.