diff --git a/src/powerpc.cpp b/src/powerpc.cpp index 64e95df96d..073dc8bbf7 100644 --- a/src/powerpc.cpp +++ b/src/powerpc.cpp @@ -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) diff --git a/test/Longs.java b/test/Longs.java index 51fad92969..284a72a8ca 100644 --- a/test/Longs.java +++ b/test/Longs.java @@ -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); } }