diff options
author | Philip Reames <listmail@philipreames.com> | 2021-08-03 10:28:02 -0700 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2021-08-03 10:28:46 -0700 |
commit | 223835f08b25b407e5343df76603639a36775c38 (patch) | |
tree | 8a1ef81e2600b98a83d722df9a3df832f67a5b82 /llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | |
parent | 53d6988171aed2c71d920b940264774f73248ca1 (diff) | |
download | llvm-223835f08b25b407e5343df76603639a36775c38.zip llvm-223835f08b25b407e5343df76603639a36775c38.tar.gz llvm-223835f08b25b407e5343df76603639a36775c38.tar.bz2 |
[runtimeunroll] A bit of style cleanup to simplify a following change [NFC]
Use for-range, use the idiomatic pattern for non-loop values, etc..
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp index e2eb001..51b4a4e 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -847,29 +847,20 @@ bool llvm::UnrollRuntimeLoopRemainder( // work is to update the phi nodes in the original loop, and take in the // values from the cloned region. for (auto *BB : OtherExits) { - for (auto &II : *BB) { - - // Given we preserve LCSSA form, we know that the values used outside the - // loop will be used through these phi nodes at the exit blocks that are - // transformed below. - if (!isa<PHINode>(II)) - break; - PHINode *Phi = cast<PHINode>(&II); - unsigned oldNumOperands = Phi->getNumIncomingValues(); + // Given we preserve LCSSA form, we know that the values used outside the + // loop will be used through these phi nodes at the exit blocks that are + // transformed below. + for (PHINode &PN : BB->phis()) { + unsigned oldNumOperands = PN.getNumIncomingValues(); // Add the incoming values from the remainder code to the end of the phi // node. - for (unsigned i =0; i < oldNumOperands; i++){ - Value *newVal = VMap.lookup(Phi->getIncomingValue(i)); - // newVal can be a constant or derived from values outside the loop, and - // hence need not have a VMap value. Also, since lookup already generated - // a default "null" VMap entry for this value, we need to populate that - // VMap entry correctly, with the mapped entry being itself. - if (!newVal) { - newVal = Phi->getIncomingValue(i); - VMap[Phi->getIncomingValue(i)] = Phi->getIncomingValue(i); - } - Phi->addIncoming(newVal, - cast<BasicBlock>(VMap[Phi->getIncomingBlock(i)])); + for (unsigned i = 0; i < oldNumOperands; i++){ + auto *PredBB =PN.getIncomingBlock(i); + auto *V = PN.getIncomingValue(i); + if (Instruction *I = dyn_cast<Instruction>(V)) + if (L->contains(I)) + V = VMap.lookup(I); + PN.addIncoming(V, cast<BasicBlock>(VMap[PredBB])); } } #if defined(EXPENSIVE_CHECKS) && !defined(NDEBUG) |