Skip to content

Commit

Permalink
Revert "[ValueTracking] Added support to deduce PHI Nodes values bein…
Browse files Browse the repository at this point in the history
…g a power of 2"

This reverts commit d5c130f.
Breaks tests, see https://reviews.llvm.org/D125332#3525819
  • Loading branch information
nico committed May 19, 2022
1 parent f613e6d commit 304a5a7
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions llvm/lib/Analysis/ValueTracking.cpp
Expand Up @@ -2128,25 +2128,6 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
}
}

// A PHI node is power of two if all incoming values are power of two.
if (const PHINode *PN = dyn_cast<PHINode>(V)) {
Query RecQ = Q;

// Recursively check all incoming values. Limit recursion to 2 levels, so
// that search complexity is limited to number of operands^2.
unsigned NewDepth = std::max(Depth, MaxAnalysisRecursionDepth - 1);
return llvm::all_of(PN->operands(), [&](const Use &U) {
// Value is power of 2 if it is coming from PHI node itself by induction.
if (U.get() == PN)
return true;

// Change the context instruction to the incoming block where it is
// evaluated.
RecQ.CxtI = PN->getIncomingBlock(U)->getTerminator();
return isKnownToBeAPowerOfTwo(U.get(), OrZero, NewDepth, RecQ);
});
}

// An exact divide or right shift can only shift off zero bits, so the result
// is a power of two only if the first operand is a power of two and not
// copying a sign bit (sdiv int_min, 2).
Expand Down

0 comments on commit 304a5a7

Please sign in to comment.