[LLVMdev] Loads not hoisted out of the loop

Owen Anderson resistor at mac.com
Thu Jan 17 21:33:19 PST 2013

On Jan 17, 2013, at 9:27 PM, Dimitri Tcaciuc <dtcaciuc at gmail.com> wrote:

> Hey everyone,
> I'm looking at the following two C functions:
>     http://pastebin.com/mYWCj6d8
> Second one is about 50% slower than the first one because in the second case d->data[i * 3 + {X, Y, Z}] loads are not moved out of the second loop and are computed every time j increments, even though they don't depend on it. If I move those out manually, the performance of the two is equal.
> What could be the reason for this behaviour? I looked at LICM logs; the compiler hoists GEPs but stops short of loading the actual values. Does it have something to do with possible aliasing?


Almost certainly, the compiler can't tell that the load from the struct (to get the array pointer) doesn't alias with the stores to the array itself.  This is exactly the kind of thing that type-based alias analysis (-fstrict-aliasing) can help with.   Use with caution, as it can break some type-unsafe idioms.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130117/3b809c0b/attachment.html>

More information about the llvm-dev mailing list