mirror of
https://github.com/Z3Prover/z3
synced 2026-02-19 23:14:40 +00:00
optimize has_sign_bit and mod2k to not compute powers of two
this is very useful for bitvectors of large bitwidths
This commit is contained in:
parent
74cbd6de32
commit
09370d7782
6 changed files with 97 additions and 34 deletions
|
|
@ -836,9 +836,7 @@ rational bv_recognizers::norm(rational const & val, unsigned bv_size, bool is_si
|
|||
|
||||
bool bv_recognizers::has_sign_bit(rational const & n, unsigned bv_size) const {
|
||||
SASSERT(bv_size > 0);
|
||||
rational m = norm(n, bv_size, false);
|
||||
rational p = rational::power_of_two(bv_size - 1);
|
||||
return m >= p;
|
||||
return numerator(n).get_bit(bv_size - 1) == 1;
|
||||
}
|
||||
|
||||
bool bv_recognizers::is_bv_sort(sort const * s) const {
|
||||
|
|
|
|||
|
|
@ -461,8 +461,7 @@ public:
|
|||
MATCH_UNARY(is_int2bv);
|
||||
bool is_bit2bool(expr* e, expr*& bv, unsigned& idx) const;
|
||||
|
||||
rational norm(rational const & val, unsigned bv_size, bool is_signed) const ;
|
||||
rational norm(rational const & val, unsigned bv_size) const { return norm(val, bv_size, false); }
|
||||
rational norm(rational const & val, unsigned bv_size, bool is_signed = false) const ;
|
||||
bool has_sign_bit(rational const & n, unsigned bv_size) const;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue