<div dir="ltr">The switch goes in the other direction: if you emit memcpy, LLVM will try pick the best operation to represent it (works in most cases, although sometimes early optimizations might get missed). If you emit load/store, it'll unroll it (usually either in SROA or legalization, iirc).<br><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 29, 2018 at 1:31 PM Bagel <<a href="mailto:bagel99@gmail.com">bagel99@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, I had noticed that if I generated memcpy, it did what I wanted.  I had<br>
hoped that there was a switch that would cause LLVM to convert a store to a<br>
memcpy if it was greater than a given size.<br>
<br>
Sigh.  Guess I'll have to do it in the front end.<br>
<br>
Thanks, brian<br>
<br>
<br>
<br>
On 10/29/18 12:27 PM, Jameson Nash wrote:<br>
> If you always generate a `memcpy` call (intrinsic) instead of load/store to<br>
> move values around, the resulting machine code will be as you want. (You might<br>
> add a heuristic that it only uses memcpy for values that are much larger than a<br>
> register, but LLVM does pretty well regardless)<br>
> <br>
> On Mon, Oct 29, 2018 at 1:08 PM Bagel via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>> wrote:<br>
> <br>
>     If a store has a type which is "large", the code generated is loop unrolled.<br>
>     For example:<br>
> <br>
>     %R = type {i32, [255 x i32]}<br>
>     @a = global %R zeroinitializer, align 4<br>
>     define void @foo(%R* %y$) nounwind {<br>
>     L.0:<br>
>             %y = alloca %R*<br>
>             store %R* %y$, %R** %y<br>
>             %0 = load %R*, %R** %y<br>
>             %1 = load %R, %R* %0<br>
>             store %R %1, %R* @a<br>
>             br label %return<br>
>     return:<br>
>             ret void<br>
>     }<br>
> <br>
>     generates a huge number of instructions.  Is there a flag somewhere (I couldn't<br>
>     find one) that which cause this store loop not to be unrolled.<br>
> <br>
>     Thanks, brian<br>
>     _______________________________________________<br>
>     LLVM Developers mailing list<br>
>     <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
>     <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> <br>
<br>
</blockquote></div></div>