Commit 42027031 authored by Miran.Karic's avatar Miran.Karic Committed by Commit Bot

MIPS: Fix liftoff bit shift operations.

The problem occurs when getting an unused register causes spilling, but
the generated code is not executed because of a branch, resulting in
loss of data.

BUG=
TEST=cctest/test-run-wasm/RunWasmLiftoff_I64Sh*

Change-Id: Icdb897df42059ed27bec57fcf91cc8338e4598f3
Reviewed-on: https://chromium-review.googlesource.com/1060213Reviewed-by: 's avatarIvica Bogosavljevic <ivica.bogosavljevic@mips.com>
Commit-Queue: Ivica Bogosavljevic <ivica.bogosavljevic@mips.com>
Cr-Commit-Position: refs/heads/master@{#53200}
parent 154f0cb3
......@@ -691,14 +691,16 @@ inline void Emit64BitShiftOperation(
pinned.set(src);
pinned.set(amount);
// If some of destination registers are in use, get another, unused pair.
// That way we prevent overwriting some input registers while shifting.
// Do this before any branch so that the cache state will be correct for
// all conditions.
LiftoffRegister tmp = assm->GetUnusedRegister(kGpRegPair, pinned);
// If shift amount is 0, don't do the shifting.
assm->TurboAssembler::Branch(&move, eq, amount, Operand(zero_reg));
if (liftoff::IsRegInRegPair(dst, amount) || dst.overlaps(src)) {
// If some of destination registers are in use, get another, unused pair.
// That way we prevent overwriting some input registers while shifting.
LiftoffRegister tmp = assm->GetUnusedRegister(kGpRegPair, pinned);
// Do the actual shift.
(assm->*emit_shift)(tmp.low_gp(), tmp.high_gp(), src.low_gp(),
src.high_gp(), amount, kScratchReg, kScratchReg2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment