aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-01-06 17:33:53 +0100
committerNikita Popov <npopov@redhat.com>2023-01-06 17:36:01 +0100
commitc60149b49e18a4cedc4c57d3bcb42d95061245f1 (patch)
tree2d88fed55d87904452602c00a4df252fc6b40fd6 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
parent1aa9862df3634d1d526e5bfd0431408a24ac435a (diff)
downloadllvm-c60149b49e18a4cedc4c57d3bcb42d95061245f1.zip
llvm-c60149b49e18a4cedc4c57d3bcb42d95061245f1.tar.gz
llvm-c60149b49e18a4cedc4c57d3bcb42d95061245f1.tar.bz2
Revert "[Dominator] Add findNearestCommonDominator() for Instructions (NFC)"
This reverts commit 7f0de9573f758f5f9108795850337a5acbd17eef. This is missing handling for !isReachableFromEntry() blocks, which may be relevant for some callers. Revert for now.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyIndVar.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 4e83d2f..a7fe065 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -106,8 +106,13 @@ static Instruction *findCommonDominator(ArrayRef<Instruction *> Instructions,
DominatorTree &DT) {
Instruction *CommonDom = nullptr;
for (auto *Insn : Instructions)
- CommonDom =
- CommonDom ? DT.findNearestCommonDominator(CommonDom, Insn) : Insn;
+ if (!CommonDom || DT.dominates(Insn, CommonDom))
+ CommonDom = Insn;
+ else if (!DT.dominates(CommonDom, Insn))
+ // If there is no dominance relation, use common dominator.
+ CommonDom =
+ DT.findNearestCommonDominator(CommonDom->getParent(),
+ Insn->getParent())->getTerminator();
assert(CommonDom && "Common dominator not found?");
return CommonDom;
}