This is the mail archive of the
mailing list for the GCC project.
auto-vectorization analysis/__builtin_assume_aligned on gcc-4.7-20120114
- From: Alexander Herz <alexander dot herz at mytum dot de>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 18 Jan 2012 18:37:38 +0100
- Subject: auto-vectorization analysis/__builtin_assume_aligned on gcc-4.7-20120114
Given this piece of code (gcc-4.7-20120114):
static void Test(Batch* block,Batch* new_block,const uint32 offs)
T* __restrict old_values
T* __restrict new_values
for(uint32 c=0;c<(BS<<1);c++) //hopefully compiler applies SIMD
I would assume that the loop is always vectorized (pointers tagged as
restricted and aligned, loop
over fixed iteration space even a power of 2, so most likely dividable
by 4), it is quite similar to vectorization example22
I run the previously mentioned g++ version with this command line:
-std=c++0x -g -O3 -msse -msse2 -msse3 -msse4.1 -Wall -Wstrict-aliasing=2
Looking at the vectorizer output (and at the generated assembly) it
looks as if the loop given above
is indeed vectorized if Test() is called from main() (vectorized 1 loop).
When the function Test() is called nested inside some complex code, it
looks as if the vectorization analysis gives up because the code is too
complex to analyze and never considers the loop inside Test() in this
context even though it should be easily vectorizeable in any context
given the hints inside Test().
Is there anything I can do, so that Test() is analyzed in all contexts?
I guess all methods that contain the
__builtin_assume_aligned hint should be considered for vectorization,
independent of their context.
Thx for your help,