@@ -10991,45 +10991,30 @@ bool ScalarEvolution::isKnownMultipleOf(
10991
10991
}
10992
10992
10993
10993
// Basic tests have failed.
10994
- // Record "S % M == 0" in the runtime Assumptions.
10995
- auto recordRuntimePredicate = [&](const SCEV *S) -> void {
10996
- auto *STy = dyn_cast<IntegerType>(S->getType());
10997
- const SCEV *SmodM =
10998
- getURemExpr(S, getConstant(ConstantInt::get(STy, M, false)));
10999
- const SCEV *Zero = getZero(STy);
11000
-
11001
- // Check whether "S % M == 0" is known at compile time.
11002
- if (isKnownPredicate(ICmpInst::ICMP_EQ, SmodM, Zero))
11003
- return;
11004
-
11005
- const SCEVPredicate *P =
11006
- getComparePredicate(ICmpInst::ICMP_EQ, SmodM, Zero);
10994
+ // Check "S % M == 0" at compile time and record runtime Assumptions.
10995
+ auto *STy = dyn_cast<IntegerType>(S->getType());
10996
+ const SCEV *SmodM =
10997
+ getURemExpr(S, getConstant(ConstantInt::get(STy, M, false)));
10998
+ const SCEV *Zero = getZero(STy);
10999
+
11000
+ // Check whether "S % M == 0" is known at compile time.
11001
+ if (isKnownPredicate(ICmpInst::ICMP_EQ, SmodM, Zero))
11002
+ return true;
11007
11003
11008
- // Detect redundant predicates.
11009
- for (auto *A : Assumptions)
11010
- if (A->implies(P, *this))
11011
- return;
11004
+ // Check whether "S % M != 0" is known at compile time.
11005
+ if (isKnownPredicate(ICmpInst::ICMP_NE, SmodM, Zero))
11006
+ return false;
11012
11007
11013
- Assumptions.push_back(P);
11014
- return;
11015
- };
11008
+ const SCEVPredicate *P = getComparePredicate(ICmpInst::ICMP_EQ, SmodM, Zero);
11016
11009
11017
- // Expressions like "n".
11018
- if (isa<SCEVUnknown>(S)) {
11019
- recordRuntimePredicate(S);
11020
- return true;
11021
- }
11022
-
11023
- // Expressions like "n + 1" and "n * 3".
11024
- if (isa<SCEVAddExpr>(S) || isa<SCEVMulExpr>(S)) {
11025
- if (SCEVExprContains(S, [](const SCEV *X) { return isa<SCEVUnknown>(X); }))
11026
- recordRuntimePredicate(S);
11027
- return true;
11028
- }
11010
+ // Detect redundant predicates.
11011
+ for (auto *A : Assumptions)
11012
+ if (A->implies(P, *this))
11013
+ return true;
11029
11014
11030
- LLVM_DEBUG(dbgs() << "SCEV node not handled yet in isKnownMultipleOf: " << *S
11031
- << "\n" );
11032
- return false ;
11015
+ // Only record non-redundant predicates.
11016
+ Assumptions.push_back(P );
11017
+ return true ;
11033
11018
}
11034
11019
11035
11020
std::pair<const SCEV *, const SCEV *>
0 commit comments