[llvm-dev] disable loop unrolling for store of large objects?

Jameson Nash via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 29 10:27:09 PDT 2018


If you always generate a `memcpy` call (intrinsic) instead of load/store to
move values around, the resulting machine code will be as you want. (You
might add a heuristic that it only uses memcpy for values that are much
larger than a register, but LLVM does pretty well regardless)

On Mon, Oct 29, 2018 at 1:08 PM Bagel via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> If a store has a type which is "large", the code generated is loop
> unrolled.
> For example:
>
> %R = type {i32, [255 x i32]}
> @a = global %R zeroinitializer, align 4
> define void @foo(%R* %y$) nounwind {
> L.0:
>         %y = alloca %R*
>         store %R* %y$, %R** %y
>         %0 = load %R*, %R** %y
>         %1 = load %R, %R* %0
>         store %R %1, %R* @a
>         br label %return
> return:
>         ret void
> }
>
> generates a huge number of instructions.  Is there a flag somewhere (I
> couldn't
> find one) that which cause this store loop not to be unrolled.
>
> Thanks, brian
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181029/ba071ca8/attachment-0001.html>


More information about the llvm-dev mailing list