https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102927
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- > As Richi said, we do the transformation to switch only if we can expand it > by jump table, bit test or array access. > > You can expand this example with: > --param case-values-threshold=4 and we end up with array access: $ gcc -c pr102927.c -O2 --param case-values-threshold=4 -fdump-tree-optimized=/dev/stdout ;; Function foo (foo, funcdef_no=0, decl_uid=1943, cgraph_uid=1, symbol_order=0) Removing basic block 5 int foo (int i) { int _1; unsigned int _3; int _4; <bb 2> [local count: 1073741824]: _3 = (unsigned int) i_2(D); if (_3 <= 3) goto <bb 3>; [50.00%] else goto <bb 4>; [50.00%] <bb 3> [local count: 536870913]: _4 = CSWTCH.1[_3]; <bb 4> [local count: 1073741824]: # _1 = PHI <42(2), _4(3)> return _1; }