[llvm-dev] Particular type of loop optimization

mats petersson via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 2 09:31:50 PST 2016


What are you actually trying to achieve?

I would have thought that [once it gets optimised enough], the compiler
does that, or something similar anyway [in particular `*aux++ = i;` would
be what I'd expect to see].
(Obviously, with global variables, there's always a bit of a problem if the
compiler believes that some other code may change `vectorE` during the
execution of `foo`, and what is expected to happen if that is the case)

--
Mats

On 2 February 2016 at 16:35, Gleison Souza via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Dear LLVMers,
>
>     I am trying to implement a particular type of loop optimization, but I
> am having problems with global variables. To solve this problem, I would
> like to know if LLVM has some pass that moves loads outside loops. I will
> illustrate with an example. I want to transform this code below. I am
> writing in C for readability, but I am analysing LLVM IR:
>
> int *vectorE;
>
> void foo (int n) {
>   int i;
>   for (i = 0; i < n; i++)
>     vectorE[i] = i;
> }
>
> into this one:
>
> int *vectorE;
>
> void foo (int n) {
>   int i;
>   int* aux = vectorE;
>   for (i = 0; i < n; i++)
>     aux[i] = i;
> }
>
> Regards,
>
> Gleison
>
> _______________________________________________
> 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/20160202/f3b7dbf0/attachment.html>


More information about the llvm-dev mailing list