diff --git a/src/powerpc.cpp b/src/powerpc.cpp index 00ebf5db04..754320c5a8 100644 --- a/src/powerpc.cpp +++ b/src/powerpc.cpp @@ -615,10 +615,8 @@ moveRR(Context* c, unsigned srcSize, Assembler::Register* src, case 4: case 8: if (srcSize == 4 and dstSize == 8) { - Assembler::Register dstHigh(dst->high); moveRR(c, 4, src, 4, dst); - moveRR(c, 4, src, 4, &dstHigh); - issue(c, srawi(dst->high, dst->high, 31)); + issue(c, srawi(dst->high, src->low, 31)); } else if (srcSize == 8 and dstSize == 8) { Assembler::Register srcHigh(src->high); Assembler::Register dstHigh(dst->high); @@ -1073,7 +1071,13 @@ andC(Context* c, unsigned size, Assembler::Constant* a, } if (state) { - issue(c, rlwinm(dst->low, b->low, 0, 31 - end, 31 - start)); + if (start != 0 or end != 31) { + issue(c, rlwinm(dst->low, b->low, 0, 31 - end, 31 - start)); + } else { + moveRR(c, 4, b, 4, dst); + } + } else { + issue(c, li(dst->low, 0)); } } } diff --git a/test/Longs.java b/test/Longs.java index 59da607517..daa6966677 100644 --- a/test/Longs.java +++ b/test/Longs.java @@ -16,6 +16,20 @@ public class Longs { putInt((int)val, dst, offset + 4); } + public static int getInt(byte[] src, int offset) { + int r = ((src[offset] & 0xFF) << 24) + | ((src[offset + 1] & 0xFF) << 16) + | ((src[offset + 2] & 0xFF) << 8) + | ((src[offset + 3] & 0xFF)); + System.out.println("get " + r); + return r; + } + + public static long getLong(byte[] src, int offset) { + return ((long) getInt(src, offset) << 32) + | ((long) getInt(src, offset + 4) & 0xffffffffL); + } + private static long roundUp(long a, long b) { a += b - 1L; return a - (a % b); @@ -174,6 +188,7 @@ public class Longs { { byte[] array = new byte[8]; putLong(231, array, 0); + expect((array[0] & 0xff) == 0); expect((array[1] & 0xff) == 0); expect((array[2] & 0xff) == 0); @@ -182,6 +197,8 @@ public class Longs { expect((array[5] & 0xff) == 0); expect((array[6] & 0xff) == 0); expect((array[7] & 0xff) == 231); + + expect(getLong(array, 0) == 231); } java.nio.ByteBuffer buffer = java.nio.ByteBuffer.allocate(8);