https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65412
Bug ID: 65412 Summary: missing control flow optimisation Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: skvadrik at gmail dot com Created attachment 35023 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35023&action=edit files 1.c (source), 1.s (gcc assembly), 2.s (clang assembly) Consider the following code: void f(int x) { if (x == 0) f0(); else if (x == 1) f1(); else if (x == 2) f2(); else if (x == 3) f3(); else if (x == 4) f4(); else if (x == 5) f5(); } gcc-4.9.2 doesn't optimize ifs to decision tree, jump table or something (see 1.s in attach). clang does (2.s in attach, jump table). Maybe you could improve that?