From 3afb974aa5e8c30eb10679afbaa6db1922b0599c Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 14 Sep 2018 07:50:20 +0000 Subject: [LoopInterchange] Preserve ScalarEvolution, by forgetting about interchanged loops. As preparation for LoopInterchange becoming a loop pass, it needs to preserve ScalarEvolution. Even though interchanging should not change the trip count of the loop, it modifies loop entry, latch and exit blocks. I added -verify-scev to some loop interchange tests, but the verification does not catch problems caused by missing invalidation of SE in loop interchange, as the trip counts themselves do not change. So there might be potential to make the SE verification covering more stuff in the future. Reviewers: mkazantsev, efriedma, karthikthecool Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D52026 llvm-svn: 342209 --- llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp index cf0e64521cb..38c9396b954 100644 --- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp @@ -454,6 +454,7 @@ struct LoopInterchange : public FunctionPass { AU.addPreserved(); AU.addPreserved(); + AU.addPreserved(); } bool runOnFunction(Function &F) override { @@ -1231,6 +1232,10 @@ void LoopInterchangeTransform::restructureLoops( // outer loop. NewOuter->addBlockEntry(OrigOuterPreHeader); LI->changeLoopFor(OrigOuterPreHeader, NewOuter); + + // Tell SE that we move the loops around. + SE->forgetLoop(NewOuter); + SE->forgetLoop(NewInner); } bool LoopInterchangeTransform::transform() { -- cgit v1.2.3