<div dir="ltr"><div style="font-size:13px">Dear LLVMers,</div><div style="font-size:13px"><br></div><div style="font-size:13px">    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:</div><div style="font-size:13px"><br></div><div style="font-size:13px">int *vectorE;</div><div style="font-size:13px"><br></div><div style="font-size:13px">void foo (int n) {       </div><div style="font-size:13px">  int i;</div><div style="font-size:13px">  for (i = 0; i < n; i++)</div><div style="font-size:13px">    vectorE[i] = i;</div><div style="font-size:13px">}</div><div style="font-size:13px"><br></div><div style="font-size:13px">into this one:</div><div style="font-size:13px"><br></div><div style="font-size:13px">int *vectorE;</div><div style="font-size:13px"><br></div><div style="font-size:13px">void foo (int n) {       </div><div style="font-size:13px">  int i;</div><div style="font-size:13px">  int* aux = vectorE;</div><div style="font-size:13px">  for (i = 0; i < n; i++)</div><div style="font-size:13px">    aux[i] = i;</div><div style="font-size:13px">}</div><div style="font-size:13px"><br></div><div style="font-size:13px">Regards,</div><div style="font-size:13px"><br></div><div style="font-size:13px">Gleison</div></div>