<div dir="ltr">Please add a testcase, too :)</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 10, 2017 at 1:16 PM, Phabricator via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This revision was automatically updated to reflect the committed changes.<br>
Closed by commit rL307581: Avoid doing conservative phi checks in aliasSameBasePointerGEPs() if no phis… (authored by faaleen).<br>
<br>
Changed prior to commit:<br>
<a href="https://reviews.llvm.org/D34478?vs=103471&id=105908#toc" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D34478?vs=103471&id=105908#toc</a><br>
<br>
Repository:<br>
rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D34478" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D34478</a><br>
<br>
Files:<br>
llvm/trunk/include/llvm/<wbr>Analysis/BasicAliasAnalysis.h<br>
llvm/trunk/lib/Analysis/<wbr>BasicAliasAnalysis.cpp<br>
llvm/trunk/lib/Analysis/<wbr>ValueTracking.cpp<br>
<br>
<br>
Index: llvm/trunk/lib/Analysis/<wbr>ValueTracking.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- llvm/trunk/lib/Analysis/<wbr>ValueTracking.cpp<br>
+++ llvm/trunk/lib/Analysis/<wbr>ValueTracking.cpp<br>
@@ -1873,7 +1873,7 @@<br>
if (Known.countMaxLeadingZeros() < BitWidth - ShiftVal)<br>
return true;<br>
// Are all the bits to be shifted out known zero?<br>
- if (Known.countMinTrailingZeros() >= ShiftVal)<br>
+ if (Known.isUnknown() || Known.countMinTrailingZeros() >= ShiftVal)<br>
return isKnownNonZero(X, Depth, Q);<br>
}<br>
}<br>
Index: llvm/trunk/lib/Analysis/<wbr>BasicAliasAnalysis.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- llvm/trunk/lib/Analysis/<wbr>BasicAliasAnalysis.cpp<br>
+++ llvm/trunk/lib/Analysis/<wbr>BasicAliasAnalysis.cpp<br>
@@ -922,11 +922,11 @@<br>
<br>
/// Provide ad-hoc rules to disambiguate accesses through two GEP operators,<br>
/// both having the exact same pointer operand.<br>
-static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,<br>
- uint64_t V1Size,<br>
- const GEPOperator *GEP2,<br>
- uint64_t V2Size,<br>
- const DataLayout &DL) {<br>
+AliasResult BasicAAResult::<wbr>aliasSameBasePointerGEPs(const GEPOperator *GEP1,<br>
+ uint64_t V1Size,<br>
+ const GEPOperator *GEP2,<br>
+ uint64_t V2Size,<br>
+ const DataLayout &DL) {<br>
<br>
assert(GEP1-><wbr>getPointerOperand()-><wbr>stripPointerCastsAndBarriers() ==<br>
GEP2->getPointerOperand()-><wbr>stripPointerCastsAndBarriers() &&<br>
@@ -1006,19 +1006,23 @@<br>
// Because they cannot partially overlap and because fields in an array<br>
// cannot overlap, if we can prove the final indices are different between<br>
// GEP1 and GEP2, we can conclude GEP1 and GEP2 don't alias.<br>
-<br>
+<br>
// If the last indices are constants, we've already checked they don't<br>
// equal each other so we can exit early.<br>
if (C1 && C2)<br>
return NoAlias;<br>
{<br>
Value *GEP1LastIdx = GEP1->getOperand(GEP1-><wbr>getNumOperands() - 1);<br>
Value *GEP2LastIdx = GEP2->getOperand(GEP2-><wbr>getNumOperands() - 1);<br>
- if (isa<PHINode>(GEP1LastIdx) || isa<PHINode>(GEP2LastIdx)) {<br>
+ if ((isa<PHINode>(GEP1LastIdx) || isa<PHINode>(GEP2LastIdx)) &&<br>
+ !VisitedPhiBBs.empty()) {<br>
// If one of the indices is a PHI node, be safe and only use<br>
// computeKnownBits so we don't make any assumptions about the<br>
// relationships between the two indices. This is important if we're<br>
// asking about values from different loop iterations. See PR32314.<br>
+ // But, with empty visitedPhiBBs we can guarantee that the values are<br>
+ // from the same iteration. Therefore, we can avoid doing this<br>
+ // conservative check.<br>
// TODO: We may be able to change the check so we only do this when<br>
// we definitely looked through a PHINode.<br>
if (GEP1LastIdx != GEP2LastIdx &&<br>
Index: llvm/trunk/include/llvm/<wbr>Analysis/BasicAliasAnalysis.h<br>
==============================<wbr>==============================<wbr>=======<br>
--- llvm/trunk/include/llvm/<wbr>Analysis/BasicAliasAnalysis.h<br>
+++ llvm/trunk/include/llvm/<wbr>Analysis/BasicAliasAnalysis.h<br>
@@ -183,6 +183,12 @@<br>
uint64_t V2Size, const AAMDNodes &V2AAInfo,<br>
const Value *UnderlyingV1, const Value *UnderlyingV2);<br>
<br>
+ AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,<br>
+ uint64_t V1Size,<br>
+ const GEPOperator *GEP2,<br>
+ uint64_t V2Size,<br>
+ const DataLayout &DL);<br>
+<br>
AliasResult aliasPHI(const PHINode *PN, uint64_t PNSize,<br>
const AAMDNodes &PNAAInfo, const Value *V2,<br>
uint64_t V2Size, const AAMDNodes &V2AAInfo,<br>
<br>
<br>
</blockquote></div><br></div>