Commit ad9835e5 authored by Predrag Rudic's avatar Predrag Rudic Committed by Commit Bot

MIPS[64]: Fix failing atomic64-stress test

64-bit implementations of ExtractBits and InsertBits were using 32-bit
instructions. Masking when representation of instruction is 64 is now
correct.
Also added optimization for 32-bit InsertBits.

Change-Id: I3d5117835daa67708e544d01d1d9058dcc0cc64e
Reviewed-on: https://chromium-review.googlesource.com/c/1355141Reviewed-by: 's avatarSreten Kovacevic <skovacevic@wavecomp.com>
Commit-Queue: Sreten Kovacevic <skovacevic@wavecomp.com>
Cr-Commit-Position: refs/heads/master@{#57961}
parent d3e40641
...@@ -1755,8 +1755,7 @@ void TurboAssembler::InsertBits(Register dest, Register source, Register pos, ...@@ -1755,8 +1755,7 @@ void TurboAssembler::InsertBits(Register dest, Register source, Register pos,
{ {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
Subu(scratch, pos, Operand(32)); Subu(scratch, zero_reg, pos);
Neg(scratch, Operand(scratch));
Ror(dest, dest, scratch); Ror(dest, dest, scratch);
} }
} }
......
...@@ -2069,7 +2069,7 @@ void TurboAssembler::Dins(Register rt, Register rs, uint16_t pos, ...@@ -2069,7 +2069,7 @@ void TurboAssembler::Dins(Register rt, Register rs, uint16_t pos,
void TurboAssembler::ExtractBits(Register dest, Register source, Register pos, void TurboAssembler::ExtractBits(Register dest, Register source, Register pos,
int size, bool sign_extend) { int size, bool sign_extend) {
srav(dest, source, pos); dsrav(dest, source, pos);
Dext(dest, dest, 0, size); Dext(dest, dest, 0, size);
if (sign_extend) { if (sign_extend) {
switch (size) { switch (size) {
...@@ -2091,14 +2091,13 @@ void TurboAssembler::ExtractBits(Register dest, Register source, Register pos, ...@@ -2091,14 +2091,13 @@ void TurboAssembler::ExtractBits(Register dest, Register source, Register pos,
void TurboAssembler::InsertBits(Register dest, Register source, Register pos, void TurboAssembler::InsertBits(Register dest, Register source, Register pos,
int size) { int size) {
Ror(dest, dest, pos); Dror(dest, dest, pos);
Dins(dest, source, 0, size); Dins(dest, source, 0, size);
{ {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
Dsubu(scratch, pos, Operand(64)); Dsubu(scratch, zero_reg, pos);
Neg(scratch, Operand(scratch)); Dror(dest, dest, scratch);
Ror(dest, dest, scratch);
} }
} }
......
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