Aliasing Question

I just have two questions regarding the following small piece of code:

if (var > start*end) {
arr[var] = arr[var-1];
}
else {
arr[var] = arr[var+1];
}

  1. Why does llvm put the address computation in the branched blocks instead of the common dominator?
  2. Why does the AliasAnalysis return MayAlias instead of MustAlias?

Thanks.

The answer to both your questions probably depends on the optimizations and other compiler flags you used.

For example, the default version of alias analysis is -no-aa which doesn't do anything but return 'may alias'.

Regards,
  Roel

Oh, I am talking about the stores (not the loads, obviously), fyi. Also, I’m curious why this simple code change:

int temp=0;
if (var > start*end) {
//arr[var] = arr[var-1];
temp = arr[var-1];
}
else {
temp = arr[var+1];
//arr[var] = arr[var+1];
}
arr[var] = temp;

Produces such different results?

Maybe this is a better question: What is the most exhaustive AA algo that I can currently use with LLVM 3.1?

I try to answer your question ,first:
Address compution located in branch block is Good, that. Will reduce
register pressure; may be you can consider lazy code motion optimization as
example.

Second,

Ryan Taylor-5 wrote