I have code with #pragma clang loop vectorize(enable)
, which enforces vectorization. For some types, this vectorization is not possible - example:
#include <string>
#include <vector>
template <typename T>
void double_entries(std::vector<T>& vec) {
#pragma clang loop vectorize(enable)
for (auto i = 0; i < 100; ++i) vec[i] = vec[i] + vec[i];
}
int main() {
auto char_vector = std::vector<char>{100};
auto string_vector = std::vector<std::string>{100};
double_entries(char_vector);
double_entries(string_vector);
}
Clang gives me a warning about that:
<source>:7:2: warning: loop not vectorized: failed explicitly specified loop vectorization [-Wpass-failed=loop-vectorize]
for (auto i = 0; i < 100; ++i) vec[i] = vec[i] + vec[i];
^
This doesn't really help if I don't know that the std::string
initialization of double_entries
is causing the problem.
Is there any way I can get clang to print all involved template instantiations? Once I can identify the problematic types using that compiler output, I can simply disable vectorization for those.