http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50257
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-09-06 09:23:59 UTC --- You could perhaps do if (__builtin_constant_p (n)) { if (n < X1) r = P1; else if (n < X2) r = P2; else if (n < X3) r = P3; ... } else what_you_do_currently. Then if the argument is seen to be a constant (can be even through optimizations), it will be optimized at compile time, otherwise it will be done at runtime. The drawbacks might be that you have the table in two places and if inlining estimations don't work correctly, the inline function might be considered too large.