https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107767
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Indeed, comparing that to int firewall3(const uint8_t *restrict data) { const uint16_t dst_port = *((const uint16_t *)data + 32); switch (dst_port) { case 15: return 1; case 23: return 1; case 47: return 1; case 45: return 1; case 42: return 1; case 1: return 1; case 2: return 1; case 3: return 1; default: return 0; } } this one is optimized correctly. In iftoswitch dump this one is much simpler though: dst_port_6 = MEM[(const uint16_t *)data_4(D) + 64B]; switch (dst_port_6) <default: <L8> [INV], case 1 ... 3: <L10> [INV], case 15: <L10> [INV], case 23: <L10> [INV], case 42: <L10> [INV], case 45: <L10> [INV], case 47: <L10> [INV]> <bb 3> : <L8>: <bb 4> : # _3 = PHI <1(2), 0(3)> <L10>: return _3; vs. dst_port_5 = MEM[(const uint16_t *)data_3(D) + 64B]; switch (dst_port_5) <default: <L25> [INV], case 1: <L22> [INV], case 2: <L23> [INV], case 3: <L24> [INV], case 15: <L17> [INV], case 23: <L18> [INV], case 42: <L21> [INV], case 45: <L20> [INV], case 47: <L19> [INV]> <bb 3> : <L17>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 4> : <L18>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 5> : <L19>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 6> : <L20>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 7> : <L21>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 8> : <L22>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 9> : <L23>: // predicted unlikely by early return (on trees) predictor. goto <bb 11>; [INV] <bb 10> : <L24>: // predicted unlikely by early return (on trees) predictor. <bb 11> : # _2 = PHI <1(4), 1(5), 1(3), 1(10), 1(9), 1(8), 1(7), 1(6), 0(2)> <L25>: return _2; but I guess switchconv should be able to handle both the same.