Fix thread modulus code to sign extend correctly.
When the width of a long long match the vector width we do not need to sign extend and using the << operator for this case is undefined.
This commit is contained in:
parent
8cbff6def0
commit
23a1ec9f53
|
|
@ -3439,11 +3439,13 @@ bool of_MOD_S(vthread_t thr, vvp_code_t cp)
|
|||
if (rv == 0)
|
||||
goto x_out;
|
||||
|
||||
/* Sign extend the signed operands. */
|
||||
if (lv & (1LL << (cp->number-1)))
|
||||
lv |= -1LL << cp->number;
|
||||
if (rv & (1LL << (cp->number-1)))
|
||||
rv |= -1LL << cp->number;
|
||||
/* Sign extend the signed operands when needed. */
|
||||
if (cp->number < 8*sizeof(long long)) {
|
||||
if (lv & (1LL << (cp->number-1)))
|
||||
lv |= -1LL << cp->number;
|
||||
if (rv & (1LL << (cp->number-1)))
|
||||
rv |= -1LL << cp->number;
|
||||
}
|
||||
|
||||
lv %= rv;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue