| ▲ | jayd16 7 hours ago | |||||||
Is there a name for duplicating function calls such that different optimizations for the same function can be compiled, but they are not fully duplicated at every call site? | ||||||||
| ▲ | fweimer 5 hours ago | parent | next [-] | |||||||
I think GCC calls the IPA (inter-procedural analysis) clones. https://gcc.gnu.org/onlinedocs/gccint/IPA-passes.html https://gcc.gnu.org/onlinedocs/gccint/Regular-IPA-passes.htm... https://gcc.gnu.org/onlinedocs/gccint/Late-IPA-passes.html | ||||||||
| ▲ | Someone 7 hours ago | parent | prev | next [-] | |||||||
I think that is called specialization (https://www.linkedin.com/posts/compilers-lab_compiler-progra...). Even if the compiler doesn’t explicitly do it, it can happen when doing subsequent optimization steps after inlining such as constant folding and dead code elimination. | ||||||||
| ||||||||
| ▲ | khuey 7 hours ago | parent | prev | next [-] | |||||||
If I understand what you're asking for correctly, function cloning. If you have f(x, y) and the compiler realizes the function optimizes nicely when y == 2 it can create a clone of f with a fixed argument y == 2, optimize that, and rewrite the appropriate call sites to call the clone. | ||||||||
| ▲ | mgaunard 6 hours ago | parent | prev | next [-] | |||||||
Compilers aren't as good at doing that one unfortunately. | ||||||||
| ▲ | taeric 7 hours ago | parent | prev | next [-] | |||||||
I think this is what the C++ world calls template specialization? | ||||||||
| ▲ | 7 hours ago | parent | prev | next [-] | |||||||
| [deleted] | ||||||||
| ▲ | mathisfun123 5 hours ago | parent | prev [-] | |||||||
specialization - i don't know if general purpose compilers do this but ML compilers specialize the hell out of kernels (based on constants, types, tensor dimensions, etc). EDIT: i'm le dumb - this is the whole point of JIT compilers. | ||||||||