Rangeanalysis: Refactor base bounds.

This commit is contained in:
Anders Schack-Mulligen
2023-12-06 15:55:26 +01:00
parent 6b178fb64a
commit 73671b6da3

View File

@@ -995,15 +995,23 @@ module RangeStage<
} }
/** /**
* Holds if `e` has an upper (for `upper = true`) or lower * Holds if `e` has an intrinsic upper (for `upper = true`) or lower
* (for `upper = false`) bound of `b`. * (for `upper = false`) bound of `b + delta` as a base case for range analysis.
*/ */
private predicate baseBound(Sem::Expr e, D::Delta b, boolean upper) { private predicate baseBound(Sem::Expr e, SemBound b, D::Delta delta, boolean upper) {
hasConstantBound(e, b, upper) includeBound(b) and
or (
upper = false and e = b.getExpr(delta) and
b = D::fromInt(0) and upper = [true, false]
semPositive(e.(Sem::BitAndExpr).getAnOperand()) or
hasConstantBound(e, delta, upper) and
b instanceof SemZeroBound
or
upper = false and
delta = D::fromInt(0) and
semPositive(e.(Sem::BitAndExpr).getAnOperand()) and
b instanceof SemZeroBound
)
} }
/** /**
@@ -1129,19 +1137,10 @@ module RangeStage<
) { ) {
not ignoreExprBound(e) and not ignoreExprBound(e) and
( (
e = b.getExpr(delta) and baseBound(e, b, delta, upper) and
(upper = true or upper = false) and
fromBackEdge = false and fromBackEdge = false and
origdelta = delta and origdelta = delta and
reason = TSemNoReason() and reason = TSemNoReason()
includeBound(b)
or
baseBound(e, delta, upper) and
b instanceof SemZeroBound and
fromBackEdge = false and
origdelta = delta and
reason = TSemNoReason() and
includeBound(b)
or or
exists(Sem::SsaVariable v, SsaReadPositionBlock bb | exists(Sem::SsaVariable v, SsaReadPositionBlock bb |
boundedSsa(v, b, delta, bb, upper, fromBackEdge, origdelta, reason) and boundedSsa(v, b, delta, bb, upper, fromBackEdge, origdelta, reason) and