[LLVMdev] Stack alignment on X86 AVX seems incorrect

Cameron McInally cameron.mcinally at nyu.edu
Thu Mar 1 15:59:26 PST 2012


On Thu, Mar 1, 2012 at 6:28 PM, Demikhovsky, Elena <
elena.demikhovsky at intel.com> wrote:

> Even if you explicitly specify –stack-alignment=16 the aligned movs are
> still generated.****
>
> It is not an issue related to ABI.
>
>
>
Right, your issue is triggered by the code I sent out earlier:

> The faulty code can be found in
function X86InstrInfo::storeRegToStackSlot(...) from
> /lib/Target/X86/X86InstrInfo.cpp.
>
>> bool isAligned = (RI.getStackAlignment() >= 16) ||
RI.canRealignStack(MF);
>

In some cases, the stack is assumed to be aligned if it's on a 16 byte or
greater boundary. Your desired alignment is 32 bytes, so aligned 256b moves
are selected which is not correct. At runtime, your stack slots could still
be aligned on a 16 byte boundary. You'll have to either:

1) Always use unaligned moves;
2) Update the code above to handle 32 byte alignment (Is this even possible
at compile time? I wouldn't think so.);
3) Align the frame and stack to 32 bytes, so that AVX spill slots are
always on 32 byte boundaries (This is what I'm proposing.);

-Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120301/3b944ee3/attachment.html>


More information about the llvm-dev mailing list