diff options
| author | Florian Hahn <florian.hahn@arm.com> | 2018-09-14 07:50:20 +0000 |
|---|---|---|
| committer | Florian Hahn <florian.hahn@arm.com> | 2018-09-14 07:50:20 +0000 |
| commit | 3afb974aa5e8c30eb10679afbaa6db1922b0599c (patch) | |
| tree | 59040c4b0ba446738347419863a2e7f30fc8283d /llvm | |
| parent | 2fa5c2833910071684403ef60ac0b82180e197bc (diff) | |
| download | bcm5719-llvm-3afb974aa5e8c30eb10679afbaa6db1922b0599c.tar.gz bcm5719-llvm-3afb974aa5e8c30eb10679afbaa6db1922b0599c.zip | |
[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
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopInterchange/interchangeable.ll | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopInterchange/phi-ordering.ll | 2 |
3 files changed, 7 insertions, 2 deletions
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<DominatorTreeWrapperPass>(); AU.addPreserved<LoopInfoWrapperPass>(); + AU.addPreserved<ScalarEvolutionWrapperPass>(); } 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() { diff --git a/llvm/test/Transforms/LoopInterchange/interchangeable.ll b/llvm/test/Transforms/LoopInterchange/interchangeable.ll index 6b9f86dfd0b..44985d8a79c 100644 --- a/llvm/test/Transforms/LoopInterchange/interchangeable.ll +++ b/llvm/test/Transforms/LoopInterchange/interchangeable.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -verify-loop-info -S | FileCheck %s +; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -verify-loop-info -verify-scev -S | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/LoopInterchange/phi-ordering.ll b/llvm/test/Transforms/LoopInterchange/phi-ordering.ll index 861313868ae..05c21129bab 100644 --- a/llvm/test/Transforms/LoopInterchange/phi-ordering.ll +++ b/llvm/test/Transforms/LoopInterchange/phi-ordering.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -loop-interchange -verify-dom-info -verify-loop-info -S 2>&1 | FileCheck %s +; RUN: opt < %s -loop-interchange -verify-dom-info -verify-loop-info -verify-scev -S 2>&1 | FileCheck %s ;; Checks the order of the inner phi nodes does not cause havoc. ;; The inner loop has a reduction into c. The IV is not the first phi. |

