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.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index c7c0815..8e2fa03e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1566,7 +1566,11 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
if (!AddRecOp1 || AddRecOp1->getLoop() != L)
return false;
+ // Check that all uses are either s/zext, or narrow def (in case of we are
+ // widening the IV increment).
for (Use &U : NarrowUse->uses()) {
+ if (U.getUser() == NarrowDef)
+ continue;
Instruction *User = nullptr;
if (ExtKind == SignExtended)
User = dyn_cast<SExtInst>(U.getUser());
@@ -1597,6 +1601,9 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
ExtendKindMap[NarrowUse] = ExtKind;
for (Use &U : NarrowUse->uses()) {
+ // Ignore narrow def: it will be removed after the transform.
+ if (U.getUser() == NarrowDef)
+ continue;
Instruction *User = nullptr;
if (ExtKind == SignExtended)
User = cast<SExtInst>(U.getUser());