[llvm] a1ed025 - Revert "[SCEV] Don't walk uses of phis without SCEV expression when forgetting"
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 15 00:45:38 PDT 2021
Author: Nikita Popov
Date: 2021-04-15T09:43:52+02:00
New Revision: a1ed025d0ef99ba76c30b3d3753e5c2c40f9b755
URL: https://github.com/llvm/llvm-project/commit/a1ed025d0ef99ba76c30b3d3753e5c2c40f9b755
DIFF: https://github.com/llvm/llvm-project/commit/a1ed025d0ef99ba76c30b3d3753e5c2c40f9b755.diff
LOG: Revert "[SCEV] Don't walk uses of phis without SCEV expression when forgetting"
This reverts commit faf9f11589ce892b31d271917cf840f8ca903221.
Issues with this patch have been reported in
https://reviews.llvm.org/D100264#2689917 and
https://bugs.llvm.org/show_bug.cgi?id=49967.
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 5f06c2926f06d..8407be99a82b1 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -2053,12 +2053,6 @@ class ScalarEvolution {
std::tuple<SCEV *, FoldingSetNodeID, void *>
findExistingSCEVInCache(SCEVTypes SCEVType, ArrayRef<const SCEV *> Ops);
- /// Push PHI nodes in the header of the given loop onto the given Worklist
- /// if they have a cached SCEV expression. If no expression is cached, then
- /// there also aren't any dependent expressions to invalidate.
- void pushCachedLoopPHIs(const Loop *L,
- SmallVectorImpl<Instruction *> &Worklist) const;
-
FoldingSet<SCEV> UniqueSCEVs;
FoldingSet<SCEVPredicate> UniquePreds;
BumpPtrAllocator SCEVAllocator;
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 446e5e3651a78..4630c5562623c 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7020,16 +7020,13 @@ bool ScalarEvolution::isBackedgeTakenCountMaxOrZero(const Loop *L) {
}
/// Push PHI nodes in the header of the given loop onto the given Worklist.
-/// Only push PHIs for which a SCEV expression has been cached, otherwise there
-/// cannot be any dependent expressions to invalidate.
-void ScalarEvolution::pushCachedLoopPHIs(
- const Loop *L, SmallVectorImpl<Instruction *> &Worklist) const {
+static void
+PushLoopPHIs(const Loop *L, SmallVectorImpl<Instruction *> &Worklist) {
BasicBlock *Header = L->getHeader();
- for (PHINode &PN : Header->phis()) {
- auto It = ValueExprMap.find_as(static_cast<Value *>(&PN));
- if (It != ValueExprMap.end())
- Worklist.push_back(&PN);
- }
+
+ // Push all Loop-header PHIs onto the Worklist stack.
+ for (PHINode &PN : Header->phis())
+ Worklist.push_back(&PN);
}
const ScalarEvolution::BackedgeTakenInfo &
@@ -7090,7 +7087,7 @@ ScalarEvolution::getBackedgeTakenInfo(const Loop *L) {
// it handles SCEVUnknown PHI nodes specially.
if (Result.hasAnyInfo()) {
SmallVector<Instruction *, 16> Worklist;
- pushCachedLoopPHIs(L, Worklist);
+ PushLoopPHIs(L, Worklist);
SmallPtrSet<Instruction *, 8> Discovered;
while (!Worklist.empty()) {
@@ -7213,7 +7210,7 @@ void ScalarEvolution::forgetLoop(const Loop *L) {
}
// Drop information about expressions based on loop-header PHIs.
- pushCachedLoopPHIs(CurrL, Worklist);
+ PushLoopPHIs(CurrL, Worklist);
while (!Worklist.empty()) {
Instruction *I = Worklist.pop_back_val();
More information about the llvm-commits
mailing list