Re:Incrementing vectors
by gpderetta on Tuesday August 27, 2019 @11:56AM
(#20811036)
If I'm reading the generated asm correctly (which I might well be not), the following function is vectorized conditional to a runtime alias check (the non vectorized case is completely removed if the pragma is uncommented). So even scalars seem to be handled:
the issue really seems to be that the compiler just gives up very early if the iteration count is not a loop invariant.
[ Parent
| on HN ]
Yeah, I read it the same as you: so alias checks can definitely happen even for single values.
It seems like it's not just the loop counts that's the problem: in the blog post even when size is a local, it fails to check to see if the vector array pointer itself can alias.
I.e., analogous to incB here:
incA is like your example: the possibly aliasing is between the array and the value added, and an alias check occurs. incB is like the v[i] example: possible aliasing is between the array and the pointer to the same array, no check and conservative code is generated.
Interesting...