summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2017-10-13 05:50:52 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2017-10-13 05:50:52 +0000
commite6b995f2b2bf639c63c34a33ab5325645ec8bd36 (patch)
tree6a480c66b7d7ef14a3af1c243fa27403ea7bc975 /llvm/unittests/Analysis/ScalarEvolutionTest.cpp
parent6794eb8ba15e9be367626774af20cc6c19dda8d7 (diff)
downloadbcm5719-llvm-e6b995f2b2bf639c63c34a33ab5325645ec8bd36.tar.gz
bcm5719-llvm-e6b995f2b2bf639c63c34a33ab5325645ec8bd36.zip
[SCEV] Maintain loop use lists, and use them in forgetLoop
Summary: Currently we do not correctly invalidate memoized results for add recurrences that were created directly (i.e. they were not created from a `Value`). This change fixes this by keeping loop use lists and using the loop use lists to determine which SCEV expressions to invalidate. Here are some statistics on the number of uses of in the use lists of all loops on a clang bootstrap (config: release, no asserts): Count: 731310 Min: 1 Mean: 8.555150 50th %time: 4 95th %tile: 25 99th %tile: 53 Max: 433 Reviewers: atrick, sunfish, mkazantsev Subscribers: mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D38434 llvm-svn: 315672
Diffstat (limited to 'llvm/unittests/Analysis/ScalarEvolutionTest.cpp')
-rw-r--r--llvm/unittests/Analysis/ScalarEvolutionTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
index f4ef32bc6f8..1f51c1c91a5 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -856,6 +856,17 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLimitForgetLoop) {
EXPECT_TRUE(isa<SCEVConstant>(EC));
EXPECT_EQ(cast<SCEVConstant>(EC)->getAPInt().getLimitedValue(), 999u);
+ // The add recurrence {5,+,1} does not correspond to any PHI in the IR, and
+ // that is relevant to this test.
+ auto *Five = SE.getConstant(APInt(/*numBits=*/64, 5));
+ auto *AR =
+ SE.getAddRecExpr(Five, SE.getOne(T_int64), Loop, SCEV::FlagAnyWrap);
+ const SCEV *ARAtLoopExit = SE.getSCEVAtScope(AR, nullptr);
+ EXPECT_FALSE(isa<SCEVCouldNotCompute>(ARAtLoopExit));
+ EXPECT_TRUE(isa<SCEVConstant>(ARAtLoopExit));
+ EXPECT_EQ(cast<SCEVConstant>(ARAtLoopExit)->getAPInt().getLimitedValue(),
+ 1004u);
+
SE.forgetLoop(Loop);
Br->eraseFromParent();
Cond->eraseFromParent();
@@ -868,6 +879,11 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLimitForgetLoop) {
EXPECT_FALSE(isa<SCEVCouldNotCompute>(NewEC));
EXPECT_TRUE(isa<SCEVConstant>(NewEC));
EXPECT_EQ(cast<SCEVConstant>(NewEC)->getAPInt().getLimitedValue(), 1999u);
+ const SCEV *NewARAtLoopExit = SE.getSCEVAtScope(AR, nullptr);
+ EXPECT_FALSE(isa<SCEVCouldNotCompute>(NewARAtLoopExit));
+ EXPECT_TRUE(isa<SCEVConstant>(NewARAtLoopExit));
+ EXPECT_EQ(cast<SCEVConstant>(NewARAtLoopExit)->getAPInt().getLimitedValue(),
+ 2004u);
}
// Make sure that SCEV invalidates exit limits after invalidating the values it
OpenPOWER on IntegriCloud