Teach BasicAA::getModRefInfo(CallSite, CallSite) some

tricks based on readnone/readonly functions.

Teach memdep to look past readonly calls when analyzing
deps for a readonly call.  This allows elimination of a
few more calls from 403.gcc:

before:
     63 gvn    - Number of instructions PRE'd
 153986 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted

after:
     63 gvn    - Number of instructions PRE'd
 153991 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted

5 calls isn't much, but this adds plumbing for the next change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60794 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2008-12-09 21:19:42 +00:00
parent 3579e44bf3
commit 20d6f0982a
4 changed files with 82 additions and 22 deletions

View File

@@ -264,10 +264,8 @@ namespace {
const Value *V2, unsigned V2Size);
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
return NoAA::getModRefInfo(CS1,CS2);
}
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2);
/// hasNoModRefInfoForCalls - We can provide mod/ref information against
/// non-escaping allocations.
virtual bool hasNoModRefInfoForCalls() const { return false; }
@@ -352,6 +350,24 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
}
AliasAnalysis::ModRefResult
BasicAliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) {
// If CS1 or CS2 are readnone, they don't interact.
ModRefBehavior CS1B = AliasAnalysis::getModRefBehavior(CS1);
if (CS1B == DoesNotAccessMemory) return NoModRef;
ModRefBehavior CS2B = AliasAnalysis::getModRefBehavior(CS2);
if (CS2B == DoesNotAccessMemory) return NoModRef;
// If they both only read from memory, just return ref.
if (CS1B == OnlyReadsMemory && CS2B == OnlyReadsMemory)
return Ref;
// Otherwise, fall back to NoAA (mod+ref).
return NoAA::getModRefInfo(CS1, CS2);
}
// alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such
// as array references. Note that this function is heavily tail recursive.
// Hopefully we have a smart C++ compiler. :)