Fix signed divide for words that match the machine word.
There was an error when calculating the negative of a value that was the same width as the native machine word. This patch is similar to what was done in 0.9 to fix the problem there.
This commit is contained in:
parent
5e401055e8
commit
b4b9667def
|
|
@ -124,14 +124,18 @@ void vvp_arith_div::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
|
|||
|
||||
unsigned sign_flip = 0;
|
||||
if (signed_flag_) {
|
||||
unsigned long sign_mask = 0;
|
||||
if (wid_ != 8*sizeof(unsigned long)) {
|
||||
sign_mask = -1UL << wid_;
|
||||
}
|
||||
if (a & (1UL << (wid_ - 1))) {
|
||||
a ^= ~(-1UL << wid_);
|
||||
a ^= ~sign_mask;
|
||||
a += 1;
|
||||
sign_flip += 1;
|
||||
}
|
||||
|
||||
if (b & (1UL << (wid_ - 1))) {
|
||||
b ^= ~(-1UL << wid_);
|
||||
b ^= ~sign_mask;
|
||||
b += 1;
|
||||
sign_flip += 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue