https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79047
Bug ID: 79047 Summary: loop annotation ignored in templated function Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fwinter at jlab dot org Target Milestone: --- Created attachment 40496 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40496&action=edit exploit #pragma GCC ivdep is ignored in a templated function: simple.cc: In member function ‘void VectorT<T>::add(const VectorT<T>&) [with T = float]’: simple.cc:37:20: warning: ignoring loop annotation for( int x = 0 ; x < r.count() ; x++ ) { simple.cc:37:20: note: loop vectorized simple.cc:37:20: note: loop versioned for vectorization because of possible aliasing simple.cc:37:20: note: loop peeled for vectorization to enhance alignment I attach an example that demonstrates this behavior. Compiled with g++ -O3 -fopt-info-vec simple.cc g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 The examples also shows that vectorization works for the same function if we remove the template. Thus, the problem is that the loop annotation is not passed down to the template instantiation of the function. (Otherwise I cannot explain the behavior as the functions are identical.)