On Fri, Oct 25, 2013 at 08:22:22AM +0200, Tobias Burnus wrote: > Jason Merrill wrote: > >On 10/10/2013 04:46 AM, Tobias Burnus wrote: > >>I considered to add the annotation also to C++11's range-based loops, > >>but as those are unlikely to vectorize, I didn't do so. > > > >I would think that a range-based loop over an array should vectorize > >nicely: > > > >int ar[8]; > >for (int i: ar) { ... } > > They do - but during my experiments they either also did without > "#pragma GCC ivdep" – typically with static arrays like yours – or > they didn't with vector<>. > > However, I came now up with an example where "#pragma GCC ivdep" > should have an effect: > > int ar[100]; > > void foo(int *a) { > for (auto &i : ar) { > i *= *a; > } > } > > Therefore, I will send a follow up patch.
What about #pragma GCC ivdep while (cond) { ... } and #pragma GCC ivdep do { ... } while (cond); (for both C and C++)? Jakub