This is an archive of the discontinued LLVM Phabricator instance.

[BasicAA] Fix recursive phi MustAlias calculations
ClosedPublic

Authored by dmgreen on Jul 1 2020, 11:24 AM.

Details

Summary

With the option -basic-aa-recphi we can detect recursive phis's that loop through constant geps, which allows us to detect more no-alias case for pointer IV's. If the other phi operand and the other alias operand are MustAlias though, we cannot presume that every element in the loop is also MustAlias. We need to instead be conservative and return MayAlias.

Diff Detail

Event Timeline

dmgreen created this revision.Jul 1 2020, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2020, 11:24 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

Commit message uses "NoAlias" where it means to use "MayAlias"?

llvm/test/Analysis/BasicAA/recphi.ll
8

NoAlias: float* %next, float* %src2 is actually correct; not sure how hard it would be to prove, though.

dmgreen edited the summary of this revision. (Show Details)Jul 1 2020, 2:27 PM
dmgreen marked an inline comment as done.Jul 1 2020, 2:35 PM

Commit message uses "NoAlias" where it means to use "MayAlias"?

Whoops. Yeah. MayAlias was what it was meant to say.

llvm/test/Analysis/BasicAA/recphi.ll
8

Yep. I left this test in because it does show it's not always better. Like you said I'm not sure how to prove that though. It might start to need something like SCEVAA. (Although in this case with the noalias - maybe it could be simpler than that).

I would like to turn this option on by default and these would all be better than (or equal) to current trunk, at least.

efriedma accepted this revision.Jul 1 2020, 2:39 PM

LGTM

This revision is now accepted and ready to land.Jul 1 2020, 2:39 PM
efriedma added inline comments.Jul 1 2020, 2:40 PM
llvm/lib/Analysis/BasicAliasAnalysis.cpp
1729

Actually, do you also need to check for PartialAlias?

dmgreen updated this revision to Diff 274930.Jul 1 2020, 2:51 PM

Now including PartialAlias too.

efriedma accepted this revision.Jul 1 2020, 3:10 PM

LGTM

This revision was automatically updated to reflect the committed changes.