diff options
author | Max Kazantsev <mkazantsev@azul.com> | 2020-12-03 17:08:35 +0700 |
---|---|---|
committer | Max Kazantsev <mkazantsev@azul.com> | 2020-12-03 18:01:41 +0700 |
commit | 4bd35cdc3ae1874c6d070c5d410b3f591de54ee6 (patch) | |
tree | 2b5f2835d6973d76a3939c136777b479ddaacf15 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | 8aeca73702d84590e32e404a2d3038399cf71418 (diff) | |
download | llvm-4bd35cdc3ae1874c6d070c5d410b3f591de54ee6.zip llvm-4bd35cdc3ae1874c6d070c5d410b3f591de54ee6.tar.gz llvm-4bd35cdc3ae1874c6d070c5d410b3f591de54ee6.tar.bz2 |
Revert "[IndVars] ICmpInst should not prevent IV widening"
This reverts commit 0c9c6ddf17bb01ae350a899b3395bb078aa0c62e.
We are seeing some failures with this patch locally. Not clear
if it's causing them or just triggering a problem in another
place. Reverting while investigating.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index e281c66..d37fe74 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -1541,14 +1541,10 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { bool CanZeroExtend = ExtKind == ZeroExtended && OBO->hasNoUnsignedWrap(); auto AnotherOpExtKind = ExtKind; - // Check that all uses are either: - // - narrow def (in case of we are widening the IV increment); - // - single-input LCSSA Phis; - // - comparison of the chosen type; - // - extend of the chosen type (raison d'etre). + // Check that all uses are either s/zext, or narrow def (in case of we are + // widening the IV increment), or single-input LCSSA Phis. SmallVector<Instruction *, 4> ExtUsers; SmallVector<PHINode *, 4> LCSSAPhiUsers; - SmallVector<ICmpInst *, 4> ICmpUsers; for (Use &U : NarrowUse->uses()) { Instruction *User = cast<Instruction>(U.getUser()); if (User == NarrowDef) @@ -1562,19 +1558,6 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { LCSSAPhiUsers.push_back(LCSSAPhi); continue; } - if (auto *ICmp = dyn_cast<ICmpInst>(User)) { - auto Pred = ICmp->getPredicate(); - // We have 3 types of predicates: signed, unsigned and equality - // predicates. For equality, it's legal to widen icmp for either sign and - // zero extend. For sign extend, we can also do so for signed predicates, - // likeweise for zero extend we can widen icmp for unsigned predicates. - if (ExtKind == ZeroExtended && ICmpInst::isSigned(Pred)) - return false; - if (ExtKind == SignExtended && ICmpInst::isUnsigned(Pred)) - return false; - ICmpUsers.push_back(ICmp); - continue; - } if (ExtKind == SignExtended) User = dyn_cast<SExtInst>(User); else @@ -1672,26 +1655,6 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { User->replaceAllUsesWith(TruncPN); DeadInsts.emplace_back(User); } - - for (ICmpInst *User : ICmpUsers) { - Builder.SetInsertPoint(User); - auto ExtendedOp = [&](Value * V)->Value * { - if (V == NarrowUse) - return WideBO; - if (ExtKind == ZeroExtended) - return Builder.CreateZExt(V, WideBO->getType()); - else - return Builder.CreateSExt(V, WideBO->getType()); - }; - auto Pred = User->getPredicate(); - auto *LHS = ExtendedOp(User->getOperand(0)); - auto *RHS = ExtendedOp(User->getOperand(1)); - auto *WideCmp = - Builder.CreateICmp(Pred, LHS, RHS, User->getName() + ".wide"); - User->replaceAllUsesWith(WideCmp); - DeadInsts.emplace_back(User); - } - return true; } |