aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp41
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;
}