Loop vectorizer doesn't try to align vectors on preferred vector alignment


I’m playing around with vectorization in LLVM 6.0.0, and I noticed that when creating a vector load out of a scalar load, the alignment for the vector load is defined to be the one of the scalar load. For instance, 16-bit vectors get aligned on 2 bytes. This does not correspond to the preferred alignment for vectors that I specified in the data layout (which is bigger).

Inspecting lib/Transforms/Vectorize/LoopVectorizer.cpp, there doesn’t seem to be an intent of doing so.
I looked at this method in particular:

void InnerLoopVectorizer::vectorizeMemoryInstruction

Is there a way (that I missed) to make this happen, or would it require a code change ? Or did I miss anything obvious ?

Thanks in advance,

  • Benoit

Hi Benoit,