llvm.org GIT mirror llvm / e582c6f
Revert r307581, "Avoid doing conservative phi checks in aliasSameBasePointerGEPs() if no phis have been visited yet." It broke stage2 tests in selfhosting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307613 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 3 years ago
3 changed file(s) with 8 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
182182 uint64_t V2Size, const AAMDNodes &V2AAInfo,
183183 const Value *UnderlyingV1, const Value *UnderlyingV2);
184184
185 AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
186 uint64_t V1Size,
187 const GEPOperator *GEP2,
188 uint64_t V2Size,
189 const DataLayout &DL);
190
191185 AliasResult aliasPHI(const PHINode *PN, uint64_t PNSize,
192186 const AAMDNodes &PNAAInfo, const Value *V2,
193187 uint64_t V2Size, const AAMDNodes &V2AAInfo,
921921
922922 /// Provide ad-hoc rules to disambiguate accesses through two GEP operators,
923923 /// both having the exact same pointer operand.
924 AliasResult BasicAAResult::aliasSameBasePointerGEPs(const GEPOperator *GEP1,
925 uint64_t V1Size,
926 const GEPOperator *GEP2,
927 uint64_t V2Size,
928 const DataLayout &DL) {
924 static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
925 uint64_t V1Size,
926 const GEPOperator *GEP2,
927 uint64_t V2Size,
928 const DataLayout &DL) {
929929
930930 assert(GEP1->getPointerOperand()->stripPointerCastsAndBarriers() ==
931931 GEP2->getPointerOperand()->stripPointerCastsAndBarriers() &&
10051005 // Because they cannot partially overlap and because fields in an array
10061006 // cannot overlap, if we can prove the final indices are different between
10071007 // GEP1 and GEP2, we can conclude GEP1 and GEP2 don't alias.
1008
1008
10091009 // If the last indices are constants, we've already checked they don't
10101010 // equal each other so we can exit early.
10111011 if (C1 && C2)
10131013 {
10141014 Value *GEP1LastIdx = GEP1->getOperand(GEP1->getNumOperands() - 1);
10151015 Value *GEP2LastIdx = GEP2->getOperand(GEP2->getNumOperands() - 1);
1016 if ((isa(GEP1LastIdx) || isa(GEP2LastIdx)) &&
1017 !VisitedPhiBBs.empty()) {
1016 if (isa(GEP1LastIdx) || isa(GEP2LastIdx)) {
10181017 // If one of the indices is a PHI node, be safe and only use
10191018 // computeKnownBits so we don't make any assumptions about the
10201019 // relationships between the two indices. This is important if we're
10211020 // asking about values from different loop iterations. See PR32314.
1022 // But, with empty visitedPhiBBs we can guarantee that the values are
1023 // from the same iteration. Therefore, we can avoid doing this
1024 // conservative check.
10251021 // TODO: We may be able to change the check so we only do this when
10261022 // we definitely looked through a PHINode.
10271023 if (GEP1LastIdx != GEP2LastIdx &&
18721872 if (Known.countMaxLeadingZeros() < BitWidth - ShiftVal)
18731873 return true;
18741874 // Are all the bits to be shifted out known zero?
1875 if (Known.isUnknown() || Known.countMinTrailingZeros() >= ShiftVal)
1875 if (Known.countMinTrailingZeros() >= ShiftVal)
18761876 return isKnownNonZero(X, Depth, Q);
18771877 }
18781878 }