https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89491
Bug ID: 89491 Summary: Inline jump tables Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: david.bolvansky at gmail dot com Target Milestone: --- int square(int x) { return x*x; } int add(int x) { return x + x; } typedef int (*p) (int); p arr[4] = {square, add}; int test(int x) { int res = arr[1](x); return res; } Expected: test(int): lea eax, [rdi+rdi] ret Currently: test(int): jmp [QWORD PTR arr[rip+8]] ------------ If the index to the jump table isn't a constant, should not be better to expand "if else" chain like: if (x==1) arr[1](x); else if (x==2) arr[2](x); ..and then take an opportunity to inline functions?