RangeAnalysis: Rename semExprModulus to exprModulus.

This commit is contained in:
Anders Schack-Mulligen
2023-11-01 16:33:40 +01:00
parent 400910e4d3
commit 7c3684dbb7
3 changed files with 13 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ import MakeTest<ModulusAnalysisTest>
private string getAModString(SemExpr e) {
exists(SemBound b, int delta, int mod |
ModulusAnalysisInstantiated::semExprModulus(e, b, delta, mod) and
ModulusAnalysisInstantiated::exprModulus(e, b, delta, mod) and
result = b.toString() + "," + delta.toString() + "," + mod.toString() and
not (delta = 0 and mod = 0)
)

View File

@@ -5,7 +5,7 @@
*/
/*
* The main recursion has base cases in both `ssaModulus` (for guarded reads) and `semExprModulus`
* The main recursion has base cases in both `ssaModulus` (for guarded reads) and `exprModulus`
* (for constant values). The most interesting recursive case is `phiModulusRankStep`, which
* handles phi inputs.
*/
@@ -229,7 +229,7 @@ module ModulusAnalysis<
b.(Bounds::SemSsaBound).getVariable() = v and pos.hasReadOfVar(v) and val = 0 and mod = 0
or
exists(Sem::Expr e, int val0, int delta |
semExprModulus(e, b, val0, mod) and
exprModulus(e, b, val0, mod) and
valueFlowStepSsa(v, pos, e, delta) and
val = remainder(val0 + delta, mod)
)
@@ -245,7 +245,7 @@ module ModulusAnalysis<
* - `mod > 1`: `val` lies within the range `[0 .. mod-1]`.
*/
cached
predicate semExprModulus(Sem::Expr e, Bounds::SemBound b, int val, int mod) {
predicate exprModulus(Sem::Expr e, Bounds::SemBound b, int val, int mod) {
e = b.getExpr(D::fromInt(val)) and mod = 0
or
evenlyDivisibleExpr(e, mod) and
@@ -259,7 +259,7 @@ module ModulusAnalysis<
)
or
exists(Sem::Expr mid, int val0, int delta |
semExprModulus(mid, b, val0, mod) and
exprModulus(mid, b, val0, mod) and
U::semValueFlowStep(e, mid, D::fromInt(delta)) and
val = remainder(val0 + delta, mod)
)
@@ -297,22 +297,22 @@ module ModulusAnalysis<
private predicate condExprBranchModulus(
Sem::ConditionalExpr cond, boolean branch, Bounds::SemBound b, int val, int mod
) {
semExprModulus(cond.getBranchExpr(branch), b, val, mod)
exprModulus(cond.getBranchExpr(branch), b, val, mod)
}
private predicate addModulus(Sem::Expr add, boolean isLeft, Bounds::SemBound b, int val, int mod) {
exists(Sem::Expr larg, Sem::Expr rarg | nonConstAddition(add, larg, rarg) |
semExprModulus(larg, b, val, mod) and isLeft = true
exprModulus(larg, b, val, mod) and isLeft = true
or
semExprModulus(rarg, b, val, mod) and isLeft = false
exprModulus(rarg, b, val, mod) and isLeft = false
)
}
private predicate subModulus(Sem::Expr sub, boolean isLeft, Bounds::SemBound b, int val, int mod) {
exists(Sem::Expr larg, Sem::Expr rarg | nonConstSubtraction(sub, larg, rarg) |
semExprModulus(larg, b, val, mod) and isLeft = true
exprModulus(larg, b, val, mod) and isLeft = true
or
semExprModulus(rarg, b, val, mod) and isLeft = false
exprModulus(rarg, b, val, mod) and isLeft = false
)
}
}

View File

@@ -230,7 +230,7 @@ signature module SignAnalysisSig<Semantic Sem> {
signature module ModulusAnalysisSig<Semantic Sem> {
class ModBound;
predicate semExprModulus(Sem::Expr e, ModBound b, int val, int mod);
predicate exprModulus(Sem::Expr e, ModBound b, int val, int mod);
}
signature module DeltaSig {
@@ -541,8 +541,8 @@ module RangeStage<
// strict then the strengthening amount is instead `k - 1` modulo `mod`:
// `x < y` means `0 <= y - x - 1 =(mod) k - 1` so `k - 1 <= y - x - 1` and
// thus `k - 1 < y - x` with `0 <= k - 1 < mod`.
semExprModulus(comp.getLesserOperand(), b, v1, mod1) and
semExprModulus(comp.getGreaterOperand(), b, v2, mod2) and
exprModulus(comp.getLesserOperand(), b, v1, mod1) and
exprModulus(comp.getGreaterOperand(), b, v2, mod2) and
mod = mod1.gcd(mod2) and
mod != 1 and
(testIsTrue = true or testIsTrue = false) and