diff options
author | Farhana Aleen <farhana.a.aleen@intel.com> | 2017-07-10 20:15:40 +0000 |
---|---|---|
committer | Farhana Aleen <farhana.a.aleen@intel.com> | 2017-07-10 20:15:40 +0000 |
commit | b0d5344402de77f795b14c0e4df433cb92a33c31 (patch) | |
tree | 1ed6fcbd312ab5c40adb298c7c7ac3d4660809f2 | |
parent | d07ce5fb3fa22a972daa31f5c155ae92348581af (diff) |
Avoid doing conservative phi checks in aliasSameBasePointerGEPs() if no phis have been visited yet.
Reviewers: Daniel Berlin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D34478
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307581 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/BasicAliasAnalysis.h | 6 | ||||
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 18 | ||||
-rw-r--r-- | lib/Analysis/ValueTracking.cpp | 2 |
3 files changed, 18 insertions, 8 deletions
diff --git a/include/llvm/Analysis/BasicAliasAnalysis.h b/include/llvm/Analysis/BasicAliasAnalysis.h index 14e4bded264..ddc0a1aac53 100644 --- a/include/llvm/Analysis/BasicAliasAnalysis.h +++ b/include/llvm/Analysis/BasicAliasAnalysis.h @@ -183,6 +183,12 @@ private: uint64_t V2Size, const AAMDNodes &V2AAInfo, const Value *UnderlyingV1, const Value *UnderlyingV2); + AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1, + uint64_t V1Size, + const GEPOperator *GEP2, + uint64_t V2Size, + const DataLayout &DL); + AliasResult aliasPHI(const PHINode *PN, uint64_t PNSize, const AAMDNodes &PNAAInfo, const Value *V2, uint64_t V2Size, const AAMDNodes &V2AAInfo, diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index b52a1d7b24d..758a907dde3 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -922,11 +922,11 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS1, /// Provide ad-hoc rules to disambiguate accesses through two GEP operators, /// both having the exact same pointer operand. -static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1, - uint64_t V1Size, - const GEPOperator *GEP2, - uint64_t V2Size, - const DataLayout &DL) { +AliasResult BasicAAResult::aliasSameBasePointerGEPs(const GEPOperator *GEP1, + uint64_t V1Size, + const GEPOperator *GEP2, + uint64_t V2Size, + const DataLayout &DL) { assert(GEP1->getPointerOperand()->stripPointerCastsAndBarriers() == GEP2->getPointerOperand()->stripPointerCastsAndBarriers() && @@ -1006,7 +1006,7 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1, // Because they cannot partially overlap and because fields in an array // cannot overlap, if we can prove the final indices are different between // GEP1 and GEP2, we can conclude GEP1 and GEP2 don't alias. - + // If the last indices are constants, we've already checked they don't // equal each other so we can exit early. if (C1 && C2) @@ -1014,11 +1014,15 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1, { Value *GEP1LastIdx = GEP1->getOperand(GEP1->getNumOperands() - 1); Value *GEP2LastIdx = GEP2->getOperand(GEP2->getNumOperands() - 1); - if (isa<PHINode>(GEP1LastIdx) || isa<PHINode>(GEP2LastIdx)) { + if ((isa<PHINode>(GEP1LastIdx) || isa<PHINode>(GEP2LastIdx)) && + !VisitedPhiBBs.empty()) { // If one of the indices is a PHI node, be safe and only use // computeKnownBits so we don't make any assumptions about the // relationships between the two indices. This is important if we're // asking about values from different loop iterations. See PR32314. + // But, with empty visitedPhiBBs we can guarantee that the values are + // from the same iteration. Therefore, we can avoid doing this + // conservative check. // TODO: We may be able to change the check so we only do this when // we definitely looked through a PHINode. if (GEP1LastIdx != GEP2LastIdx && diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 9e042da8801..704b5ebfa68 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -1873,7 +1873,7 @@ bool isKnownNonZero(const Value *V, unsigned Depth, const Query &Q) { if (Known.countMaxLeadingZeros() < BitWidth - ShiftVal) return true; // Are all the bits to be shifted out known zero? - if (Known.countMinTrailingZeros() >= ShiftVal) + if (Known.isUnknown() || Known.countMinTrailingZeros() >= ShiftVal) return isKnownNonZero(X, Depth, Q); } } |