Skip to content

Commit

Permalink
smt: simplify extract from ashr (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
can-leh-emmtrix authored Oct 31, 2024
1 parent 1665a69 commit 2a95c52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions smt/expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ bool expr::isSignExt(expr &val) const {
return isUnOp(val, Z3_OP_SIGN_EXT);
}

bool expr::isAShr(expr &a, expr &b) const {
return isBinOp(a, b, Z3_OP_BASHR);
}

bool expr::isAnd(expr &a, expr &b) const {
return isBinOp(a, b, Z3_OP_AND);
}
Expand Down Expand Up @@ -1851,6 +1855,15 @@ expr expr::extract(unsigned high, unsigned low, unsigned depth) const {
return val.sext(high - val_bits + 1);
}
}
{
expr a, b;
if (isAShr(a, b)) {
uint64_t shift;
if (b.isUInt(shift) && high + shift < a.bits()) {
return a.extract(high + shift, low + shift);
}
}
}
{
expr a, b;
if (isConcat(a, b)) {
Expand Down
1 change: 1 addition & 0 deletions smt/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class expr {
bool isConcat(expr &a, expr &b) const;
bool isExtract(expr &e, unsigned &high, unsigned &low) const;
bool isSignExt(expr &val) const;
bool isAShr(expr &a, expr &b) const;
bool isAnd(expr &a, expr &b) const;
bool isNot(expr &neg) const;
bool isAdd(expr &a, expr &b) const;
Expand Down

0 comments on commit 2a95c52

Please sign in to comment.