From 91f481665ed06bcea86b7e01a094a9f0718faec4 Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Mon, 23 Apr 2018 12:33:31 +0000 Subject: [LoopRotate] Fix incorrect SCEV invalidation in loop rotation LoopRotate only invalidates innermost loops while the changes that it makes may also affert any of this parents. With patch rL329047, SCEV becomes much smarter about calculation of exit counts for outer loops, so we cannot assume that they are not affected. Differential Revision: https://reviews.llvm.org/D45945 llvm-svn: 330582 --- llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index d96c1014877..d2a2e40518f 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -259,9 +259,10 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { return false; // Anything ScalarEvolution may know about this loop or the PHI nodes - // in its header will soon be invalidated. + // in its header will soon be invalidated, and it can also affect its parent + // loops as well. if (SE) - SE->forgetLoop(L); + SE->forgetTopmostLoop(L); DEBUG(dbgs() << "LoopRotation: rotating "; L->dump()); @@ -476,6 +477,12 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { DEBUG(dbgs() << "LoopRotation: into "; L->dump()); +#ifndef NDEBUG + // Make sure that after all our transforms SE is correct. + if (SE) + SE->verify(); +#endif + ++NumRotated; return true; } -- cgit v1.2.3