Attached is a test case. Using 2.9 opt with -basicaa -tbaa in either order plus -gvn the code is optimized well, computed values are reused, etc. because the stores and non aliasing.<br>Using llvm 3.0 the order of basicaa and tbaa makes a difference: -basicaa -tbaa optimizes, -tbaa -basicaa doesnt. That's why I tried reversing the order of calls in the alias analysis pass setup. <br>
<br><div class="gmail_quote">On Mon, Jan 30, 2012 at 6:04 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div class="h5">On Fri, 2012-01-27 at 16:46 -0800, Dan Gohman wrote:<br>
> On Jan 27, 2012, at 4:15 PM, Maurice Marks wrote:<br>
><br>
> > Our application generates IR that is used to generate X86_64 code for a Jit. We noticed that code generated with llvm 3.0 is worse in some circumstances that it was with 2.9. I traced the differences to alias analysis differences. Our IR references data structures that have lots of derived pointers and we use extensive tbaa metadata to indicate which pointers dont alias. Some of this seemed to be getting ignored in 3.0. I found by using opt on our IR that the ordering of the basicaa and tbaa optimization passes made all the difference. Code in addInitialAliasAnalysisPasses() adds the tbaa pass then basicaa pass. From Chris' comments in the forum about backward chaining of alais analysis that would execute basicaa before tbaa - and that would have the effect of basicaa doing the first pass of analysis followed by tbaa, possibly overriding the "wont alias" information we provided in the IR.  The comments in the code imply that tbaa executes first.<br>

> ><br>
> > As an experiment I reversed the order of the passes in addInitialAliasAnalysisPasses, rebuilt llvm 3.0 and our application and reran our alias  tests. Now we get the same (good) results as llvm 2.9.<br>
> ><br>
> > So my question is - which order is correct? I would expect that explicit tbaa tags that say that some pointers dont alias should have precedence.<br>
><br>
> The intention is for BasicAA to take precedence over TBAA.<br>
><br>
> Whenever BasicAA says MustAlias, it's because the pointers really<br>
> do alias, even if TBAA would say NoAlias. There's no utility in<br>
> letting TBAA's NoAlias win in this case, because the code is<br>
> either intentionally type punning, or it's buggy.<br>
><br>
> There is one special case where BasicAA can't determine the<br>
> aliasing relationship and still overrides TBAA, which is the case<br>
> where the two memory locations have the same base address and<br>
> potentially differing dynamic offsets. Special-casing this is a<br>
> mild hack used to work around the fact that the TBAA implementation<br>
> can't easily do the right thing for C code in the real world.<br>
> Possibly this is causing the loss of precision you're seeing.<br>
<br>
</div></div>Maurice, can you please provide a test case that demonstrates the<br>
problem that you're seeing?<br>
<br>
Dan, where in the code is this done? I see a comment at the end of<br>
BasicAliasAnalysis::aliasGEP regarding "protecting TBAA in the case of<br>
dynamic indices into arrays of unions"; are you referring to that?<br>
<br>
 -Hal<br>
<br>
><br>
> Dan<br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<font color="#888888"><br>
--<br>
Hal Finkel<br>
Postdoctoral Appointee<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Not sent from my Blackberry, Raspberry or Gooseberry!<br>