Open
Description
When calling an ACLE Multi Versioned function from another that is also versioned, we should statically resolve that specific callsite to allow inlining.
Proposed semantics: take the caller's feature set, and consider all callee versions with features that are in that subset, sort them according to their priority the same way the resolver would choose, and emit a remark explaining which one was picked. Worst case, pick the default implementation of the callee.
I.e. given:
__attribute__((target_version("simd")))
int callee() {
return 1;
}
__attribute__((target_version("default")))
int callee() {
return 0;
}
__attribute__((target_version("simd")))
int caller() {
return 4 + callee();
}
__attribute__((target_version("default")))
int caller() {
return 2 + callee();
}
int main() {
return caller();
}
We should resolve some of the call sites in the IR to the equivalent of:
__attribute__((target_version("simd")))
int callee() {
return 1;
}
__attribute__((target_version("default")))
int callee() {
return 0;
}
__attribute__((target_version("simd")))
int caller() {
return 4 + _callee._Msimd();
}
__attribute__((target_version("default")))
int caller() {
return 2 + _callee();
}
int main() {
return caller();
}
so that the simd
version of caller
can be optimized to:
__attribute__((target_version("simd")))
int caller() {
return 5;
}