[PATCH] D64553: [LoopUtils] Extend the scope of getLoopEstimatedTripCount
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 14 20:45:20 PDT 2019
skatkov marked an inline comment as done.
skatkov added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:628
// Get the branch weights for the loop's backedge.
- BranchInst *LatchBR =
- dyn_cast<BranchInst>(L->getLoopLatch()->getTerminator());
- if (!LatchBR || LatchBR->getNumSuccessors() != 2)
+ BasicBlock *Latch = L->getLoopLatch();
+ BranchInst *LatchBR = dyn_cast<BranchInst>(Latch->getTerminator());
----------------
reames wrote:
> There's a missing correctness check here. There's no guarantee that a loop *must* have a unique latch, so you need null check the result before dereferencing. Non unique latches are non-canonical, so you can just bail on that case.
>
> Note that unique exit implies unique latch previously.
To be honest I do not understand how unique exit implies unique latch but I can add additional check.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64553/new/
https://reviews.llvm.org/D64553
More information about the llvm-commits
mailing list