diff options
author | Florian Hahn <flo@fhahn.com> | 2022-10-07 16:07:17 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2022-10-07 16:07:17 +0100 |
commit | 9e931439ddb9b6b8f655940b9d8ed6db50c2a7e2 (patch) | |
tree | 108aa0b219a54ab3905afbdaf4d1647ea63e47d5 /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 3b652fc6d6447aae91c9e8c35815eed19245757d (diff) | |
download | llvm-9e931439ddb9b6b8f655940b9d8ed6db50c2a7e2.zip llvm-9e931439ddb9b6b8f655940b9d8ed6db50c2a7e2.tar.gz llvm-9e931439ddb9b6b8f655940b9d8ed6db50c2a7e2.tar.bz2 |
[SCEV] Support clearing Block/LoopDispositions for a single value.
Extend forgetBlockAndLoopDisposition to allow clearing information for a
single value. This can be useful when only a single value is changed,
e.g. because the instruction is moved.
We also need to clear the cached values for all SCEV users, because they
may depend on the starting value's disposition.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D134614
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 16085f4..f247a7e 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -647,20 +647,22 @@ ReprocessLoop: Instruction *Inst = &*I++; if (Inst == CI) continue; + bool InstInvariant = false; if (!L->makeLoopInvariant( - Inst, AnyInvariant, + Inst, InstInvariant, Preheader ? Preheader->getTerminator() : nullptr, MSSAU)) { AllInvariant = false; break; } + if (InstInvariant && SE) { + // The loop disposition of all SCEV expressions that depend on any + // hoisted values have also changed. + SE->forgetBlockAndLoopDispositions(Inst); + } + AnyInvariant |= InstInvariant; } - if (AnyInvariant) { + if (AnyInvariant) Changed = true; - // The loop disposition of all SCEV expressions that depend on any - // hoisted values have also changed. - if (SE) - SE->forgetLoopDispositions(); - } if (!AllInvariant) continue; // The block has now been cleared of all instructions except for |