[LLVMdev] MCJIT generates MOVAPS on unaligned address

Frank Winter
Thu, 07 Aug 2014 19:42:59 -0000

MCJIT when lowering to x86-64 generates a MOVAPS (Move Aligned Packed
Single-Precision Floating-Point Values) on a non-aligned memory address:

     movaps    88(%rdx), %xmm0

where %rdx comes in as a function argument with only natural alignment
(float*). This x86 instruction requires the memory address to be 16 byte
aligned which 88 plus something aligned to 4 byte isn't.

Here the according IR code which was produced from the SLP vectorizer:

define void @func(float* noalias %arg0, float* noalias %arg1, float*
noalias %arg2) {
entrypoint:
...
   %104 = getelementptr float* %arg0, i32 22
...
   %204 = bitcast float* %104 to <4 x float>*
   store <4 x float> %198, <4 x float>* %204

This in itself not wrong. However, shouldn't the lowering pass recognize
the wrong alignment?

I am using LLVM 3.4.2 as available as source code from llvm.org.

Thanks,
Frank