aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2021-05-14 10:15:30 -0700
committerPhilip Reames <listmail@philipreames.com>2021-05-14 10:15:30 -0700
commite488bf815fbdb78a1182cbde8a9e01a4a7ea4028 (patch)
treeca8721cce3684512074dcdbfbda52d36857d2814 /llvm/lib/Transforms/Utils/LoopUnroll.cpp
parent9d1a61e695eb01298e26c76867d65592f1e1968c (diff)
downloadllvm-e488bf815fbdb78a1182cbde8a9e01a4a7ea4028.zip
llvm-e488bf815fbdb78a1182cbde8a9e01a4a7ea4028.tar.gz
llvm-e488bf815fbdb78a1182cbde8a9e01a4a7ea4028.tar.bz2
Revert "Do actual DCE in LoopUnroll"
This reverts commit 9d1a61e695eb01298e26c76867d65592f1e1968c. I'd missed some review feedback, and had missed updating an aarch64 test. Reverting while I fix both.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnroll.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 9a1f812..893b918 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -220,10 +220,10 @@ void llvm::simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI,
}
}
- // At this point, the code is well formed. Perform constprop, instsimplify,
- // and dce.
+ // At this point, the code is well formed. We now do a quick sweep over the
+ // inserted code, doing constant propagation and dead code elimination as we
+ // go.
const DataLayout &DL = L->getHeader()->getModule()->getDataLayout();
- SmallVector<WeakTrackingVH, 16> DeadInsts;
for (BasicBlock *BB : L->getBlocks()) {
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;) {
Instruction *Inst = &*I++;
@@ -232,15 +232,14 @@ void llvm::simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI,
if (LI->replacementPreservesLCSSAForm(Inst, V))
Inst->replaceAllUsesWith(V);
if (isInstructionTriviallyDead(Inst))
- DeadInsts.emplace_back(Inst);
+ BB->getInstList().erase(Inst);
}
}
- while (!DeadInsts.empty()) {
- Value *V = DeadInsts.pop_back_val();
- if (Instruction *Inst = dyn_cast_or_null<Instruction>(V))
- RecursivelyDeleteTriviallyDeadInstructions(Inst);
- }
+ // TODO: after peeling or unrolling, previously loop variant conditions are
+ // likely to fold to constants, eagerly propagating those here will require
+ // fewer cleanup passes to be run. Alternatively, a LoopEarlyCSE might be
+ // appropriate.
}
/// Unroll the given loop by Count. The loop must be in LCSSA form. Unrolling