@@ -1032,25 +1032,18 @@ void State::addInfoForInductions(BasicBlock &BB) {
1032
1032
DTN, CmpInst::ICMP_SLT, PN, B,
1033
1033
ConditionTy (CmpInst::ICMP_SLE, StartValue, B)));
1034
1034
1035
+ // Try to add condition from header to the exit blocks. When exiting either
1036
+ // with EQ or NE in the header, we know that the induction value must be u<=
1037
+ // B, as other exits may only exit earlier.
1035
1038
assert (!StepOffset.isNegative () && " induction must be increasing" );
1036
- // Try to add condition from header to the unique exit block, if there is one.
1037
- // When exiting either with EQ or NE, we know that the induction value must be
1038
- // u<= B, as a different exit may exit earlier.
1039
- ConditionTy Precond;
1040
- if (!MonotonicallyIncreasingUnsigned)
1041
- Precond = {CmpInst::ICMP_ULE, StartValue, B};
1042
- if (Pred == CmpInst::ICMP_EQ) {
1043
- BasicBlock *EB = cast<BranchInst>(BB.getTerminator ())->getSuccessor (0 );
1044
- if (L->getUniqueExitBlock () == EB) {
1045
- WorkList.emplace_back (FactOrCheck::getConditionFact (
1046
- DT.getNode (EB), CmpInst::ICMP_ULE, A, B, Precond));
1047
- }
1048
- }
1049
- if (Pred == CmpInst::ICMP_NE) {
1050
- BasicBlock *EB = cast<BranchInst>(BB.getTerminator ())->getSuccessor (1 );
1051
- if (L->getUniqueExitBlock () == EB)
1052
- WorkList.emplace_back (FactOrCheck::getConditionFact (
1053
- DT.getNode (EB), CmpInst::ICMP_ULE, A, B, Precond));
1039
+ assert ((Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_NE) &&
1040
+ " unsupported predicate" );
1041
+ ConditionTy Precond = {CmpInst::ICMP_ULE, StartValue, B};
1042
+ SmallVector<BasicBlock *> ExitBBs;
1043
+ L->getExitBlocks (ExitBBs);
1044
+ for (BasicBlock *EB : ExitBBs) {
1045
+ WorkList.emplace_back (FactOrCheck::getConditionFact (
1046
+ DT.getNode (EB), CmpInst::ICMP_ULE, A, B, Precond));
1054
1047
}
1055
1048
}
1056
1049
0 commit comments