[PATCH] libstdc++: Use canonical loop form in std::reduce
Marc Glisse
marc.glisse@inria.fr
Fri Jan 31 14:46:05 GMT 2025
On Fri, 31 Jan 2025, Abhishek Kaushik wrote:
> The current while loop in std::reduce and related functions is hard to
> vectorize because the loop control variable is hard to detect in icx.
>
> `while ((__last - __first) >= 4)`
>
> Changing the loop header to a for loop following the OpenMP canonical
> form allows easy vectorization, resulting in improved performance.
>
> `for (; __first <= __last - 4; __first += 4)`
Is that always legal? If the sequence has size 1, is __last - 4 well
defined?
--
Marc Glisse
More information about the Libstdc++
mailing list