I now see that manually-vectorizing ranges::minmax in #4384 was not necessarily a good idea.
Original implementation was implemented in terms of minmax_element and was not vectorized.
But if it was implemented directly, it would have been vectorized.
Consider the following:
unsigned int* max_element(unsigned int*b, unsigned int* e){
unsigned int m = *b;
unsigned int* r = b;
for (++b; b != e; ++b){
if (m < *b) {
m = *b;
r = b;
}
}
return b;
}
unsigned int max1(unsigned int*b, unsigned int* e){
return *max_element(b, e);
}
unsigned int max2(unsigned int *b, unsigned int* e){
unsigned int m = *b;
for (++b; b != e; ++b){
if (m < *b) {
m = *b;
}
}
return m;
}
max1 is not vectorized, but max2 is. see https://godbolt.org/z/fG6Yzfz4v
So we could just reimplement ranges::max_element in headers and enjoy vectorization with more context.
Question how should we proceed:
- Keep manual vectorization forever
- Drop it in vNext
- Drop it any time
I now see that manually-vectorizing
ranges::minmaxin #4384 was not necessarily a good idea.Original implementation was implemented in terms of
minmax_elementand was not vectorized.But if it was implemented directly, it would have been vectorized.
Consider the following:
max1is not vectorized, butmax2is. see https://godbolt.org/z/fG6Yzfz4vSo we could just reimplement
ranges::max_elementin headers and enjoy vectorization with more context.Question how should we proceed: