A possible optimization in some cases is to construct a function with multiple entry points. This can save in both size and speed in certain cases.
#include <stdio.h> /* Example function that does something complex enough not to be optimized away */ static foo(int x) { int i; int j = x; for (i = 0; i < 1024; i++) { j += printf("%d%d%d\n", i); } return j; } /* Since foo is static and whose address is never taken, foo1 can have the same address as foo. */ int foo1(int x) { return foo(x); } /* This function could point to an "add $1, %rdi" instruction immediately before foo. (Giving foo two entry points.) */ int foo2(int x) { return foo(x + 1); } At the moment, GCC will at -O3 construct two cloned versions of foo for foo1 and foo2. At -Os, it will jump to foo in foo1 and foo2. With multiple entry points, the code can be as fast as generated for -O3 but be half the size, slightly smaller than the current -Os. -- Summary: GCC doesn't create functions with multiple entry points. Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: svfuerst at gmail dot com GCC build triplet: x86_64-linux GCC host triplet: x86_64-linux GCC target triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45058