fix 32-bit shift case in unsignedShiftRightC

This commit is contained in:
Joel Dice 2009-08-11 12:36:25 -06:00
parent 2f864ebea5
commit 935329d7cf
2 changed files with 15 additions and 5 deletions

View File

@ -501,11 +501,19 @@ void unsignedShiftRightR(Context* con, unsigned size, Reg* a, Reg* b, Reg* t)
}
}
void
moveRR(Context* c, unsigned srcSize, Assembler::Register* src,
unsigned dstSize, Assembler::Register* dst);
void unsignedShiftRightC(Context* con, unsigned size, Const* a, Reg* b, Reg* t)
{
int sh = getVal(a);
if (size == 8) {
if (sh < 32) {
if (sh == 32) {
Assembler::Register high(b->high);
moveRR(con, 4, &high, 4, t);
issue(con, li(H(t),0));
} else if (sh < 32) {
issue(con, srwi(R(t), R(b), sh));
issue(con, rlwimi(R(t),H(b),32-sh,0,sh-1));
issue(con, rlwinm(H(t),H(b),32-sh,sh,31));
@ -596,10 +604,6 @@ jumpR(Context* c, unsigned size UNUSED, Assembler::Register* target)
issue(c, bctr());
}
void
moveRR(Context* c, unsigned srcSize, Assembler::Register* src,
unsigned dstSize, Assembler::Register* dst);
void
swapRR(Context* c, unsigned aSize, Assembler::Register* a,
unsigned bSize, Assembler::Register* b)

View File

@ -39,6 +39,10 @@ public class Longs {
return -1;
}
private static long unsignedShiftRight32(long x) {
return x >>> 32;
}
public static void main(String[] args) {
expect(((long) negativeOne()) == -1);
@ -211,6 +215,8 @@ public class Longs {
buffer.putLong(231);
buffer.flip();
expect(buffer.getLong() == 231);
expect(unsignedShiftRight32(231) == 0);
}
}