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.
(cherry picked from commit 23a1ec9f53)
This commit is contained in:
parent
dbcbaab847
commit
2b63da8920
|
|
@ -3422,11 +3422,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