[PATCH] D33136: [ValueTracking] Don't let isAddOfNonZero look at adds with a PHI node as input
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 10:17:40 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305481: [BasicAA] Don't call isKnownNonEqual if we might be have gone through a PHINode. (authored by ctopper).
Changed prior to commit:
https://reviews.llvm.org/D33136?vs=99173&id=102684#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33136
Files:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Index: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1011,10 +1011,24 @@
// equal each other so we can exit early.
if (C1 && C2)
return NoAlias;
- if (isKnownNonEqual(GEP1->getOperand(GEP1->getNumOperands() - 1),
- GEP2->getOperand(GEP2->getNumOperands() - 1),
- DL))
- return NoAlias;
+ {
+ Value *GEP1LastIdx = GEP1->getOperand(GEP1->getNumOperands() - 1);
+ Value *GEP2LastIdx = GEP2->getOperand(GEP2->getNumOperands() - 1);
+ if (isa<PHINode>(GEP1LastIdx) || isa<PHINode>(GEP2LastIdx)) {
+ // 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.
+ // TODO: We may be able to change the check so we only do this when
+ // we definitely looked through a PHINode.
+ KnownBits Known1 = computeKnownBits(GEP1LastIdx, DL);
+ KnownBits Known2 = computeKnownBits(GEP2LastIdx, DL);
+ if (Known1.Zero.intersects(Known2.One) ||
+ Known1.One.intersects(Known2.Zero))
+ return NoAlias;
+ } else if (isKnownNonEqual(GEP1LastIdx, GEP2LastIdx, DL))
+ return NoAlias;
+ }
return MayAlias;
} else if (!LastIndexedStruct || !C1 || !C2) {
return MayAlias;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33136.102684.patch
Type: text/x-patch
Size: 1626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170615/69dd030d/attachment.bin>
More information about the llvm-commits
mailing list