diff options
author | Philip Reames <listmail@philipreames.com> | 2021-03-13 15:02:48 -0800 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2021-03-13 15:25:02 -0800 |
commit | 7d38a91a7f3d3bc749636d6e698a5860f38ec20a (patch) | |
tree | d1517c0d49e88d2bc0591479fbdf45f39a0f9fea /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 9228f2f3225bb7276d33af7658f6ba19c3037f4d (diff) | |
download | llvm-7d38a91a7f3d3bc749636d6e698a5860f38ec20a.zip llvm-7d38a91a7f3d3bc749636d6e698a5860f38ec20a.tar.gz llvm-7d38a91a7f3d3bc749636d6e698a5860f38ec20a.tar.bz2 |
Restore fixed version of "[CodeGenPrepare] Fix isIVIncrement (PR49466)"
Change was reverted in commit 8d20f2c2c66eb486ff23cc3d55a53bd840b36971 because it was causing an infinite loop. 9228f2f32 fixed the root issue in the code structure, this change just reapplies the original change w/adaptation to the new code structure.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 0182cdf..8e24c86d 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1332,7 +1332,7 @@ getIVIncrement(const PHINode *PN, const LoopInfo *LI) { return None; auto *IVInc = dyn_cast<Instruction>(PN->getIncomingValueForBlock(L->getLoopLatch())); - if (!IVInc) + if (!IVInc || LI->getLoopFor(IVInc->getParent()) != L) return None; Instruction *LHS = nullptr; Constant *Step = nullptr; @@ -1363,6 +1363,7 @@ bool CodeGenPrepare::replaceMathCmpWithIntrinsic(BinaryOperator *BO, if (!isIVIncrement(BO, LI)) return false; const Loop *L = LI->getLoopFor(BO->getParent()); + assert(L && "L should not be null after isIVIncrement()"); // Do not risk on moving increment into a child loop. if (LI->getLoopFor(Cmp->getParent()) != L) return false; |