<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
-----Original Message-----<br></blockquote><div> ...</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Subject: Re: [LLVMdev] Stack alignment on X86 AVX seems incorrect<br>

<br>
On Thu, Mar 01, 2012 at 06:16:46PM +0000, Demikhovsky, Elena wrote:<br>
> vmovaps should not access stack if it is not aligned to 32<br>
<br>
I'm not completely sure I understand your problem. Are you saying that<br>
the generated code assumes 256bit alignment, your default stack<br>
alignment is 128bit and LLVM doesn't adjust it automatically?<br>
<br>
Joerg<br></blockquote><div><br></div><div>Hey Joerg,</div><div><br></div><div>The faulty code can be found in function X86InstrInfo::storeRegToStackSlot(...) from /lib/Target/X86/X86InstrInfo.cpp.</div><div><br></div><div>
> bool isAligned = (RI.getStackAlignment() >= 16) || RI.canRealignStack(MF);</div><div><br></div><div>When creating the spill's machine instruction, the spill slot is assumed to be aligned if the alignment is >= 16 bytes, which is not the case for AVX. AVX spills require 32 byte alignment to make use of aligned moves. The stack is not adjusted automatically.</div>
<div><br></div><div>For performance, the best fix is to align the frame to a 32-byte boundary, ensuring that the YMM spill slots are also on 32-byte boundaries. This, of course, breaks the ABI.</div><div><br></div><div>-Cameron</div>
</div>