mirror of
https://github.com/yuzu-mirror/dynarmic.git
synced 2026-04-21 06:03:42 +00:00
u128: StickyLogicalShiftRight requires special-casing for amount == 64
In this case (128 - amount) == 64, and this invokes undefined behaviour
This commit is contained in:
parent
49c7edf7c6
commit
76b07d6646
2 changed files with 29 additions and 0 deletions
|
|
@ -112,6 +112,16 @@ u128 StickyLogicalShiftRight(u128 operand, int amount) {
|
|||
return result;
|
||||
}
|
||||
|
||||
if (amount == 64) {
|
||||
u128 result;
|
||||
result.lower = operand.upper;
|
||||
// Sticky bit
|
||||
if (operand.lower != 0) {
|
||||
result.lower |= 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (amount < 128) {
|
||||
u128 result;
|
||||
result.lower = operand.upper >> (amount - 64);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue