<div dir="ltr">Because unaligned load/store are illegal on my target.<div>But ExpandUnalignedStore expand to too many load/store. <br></div><div><br></div><div>It seem that ExpandUnalignedStore is called after the vectorization cost analysis is done and not taken into account.</div>
<div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 19, 2013 at 4:32 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Fri, Jul 19, 2013 at 1:14 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com">pichet2000@gmail.com</a>> wrote:<br>

><br>
> What is the proper solution to disable auto-vectorization for unaligned<br>
> data?<br>
<br>
</div>Why are you trying to do this?  If auto-vectorization is making a<br>
given loop slower on your target, that means the cost metrics are off,<br>
and we should fix them.  If code size is an issue, you should tell the<br>
optimizer that you want to optimize for size.<br>
<br>
-Eli<br>
<div><div class="h5"><br>
> I have an out of tree target and I added this:<br>
><br>
> bool OpusTargetLowering::allowsUnalignedMemoryAccesses(EVT VT, bool *Fast)<br>
> const {<br>
>   if (VT.isVector())<br>
>     return false;<br>
> ....<br>
> }<br>
><br>
> After that, I could see that vectorization is still done on unaligned data<br>
> except that llvm will copy the data back and forth from the source to the<br>
> top of the stack and work from there. This is very costly, I rather get<br>
> scalar operations.<br>
><br>
> Then I tried to add:<br>
>   unsigned getMemoryOpCost(unsigned Opcode, Type *Src,<br>
>                            unsigned Alignment,<br>
>                            unsigned AddressSpace) const {<br>
>     if (Src->isVectorTy() && Alignment != 16)<br>
>       return 10000; // <== high number to try to avoid unaligned load/store.<br>
>     return TargetTransformInfo::getMemoryOpCost(Opcode, Src, Alignment,<br>
> AddressSpace);<br>
>   }<br>
><br>
> Except that this doesn't work because Alignment will always be 4 even for<br>
> data like:<br>
>        int   data[16][16] __attribute__ ((aligned (16))),<br>
><br>
> Because individual element are still 4-byte aligned.<br>
><br>
> I am not sure what is the right way to do it?<br>
> Thanks.<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
</blockquote></div><br></div></div></div>