This one was a pain to track down.  Attached is a test program.

Vince


# HG changeset patch
# User Vince Weaver <[email protected]>
# Date 1257372942 18000
# Node ID 5d1ef2e22e7ce7a25e5bbfd4c705987190a1e9d3
# Parent  cf6a2dce697bd722b0de2b84311a536155f7b439
X86: Fix cvti2f mediaop

The cvti2f mediaop wasn't properly casting a "1" being shifted to ULL,
so that it defaulted to 32-bits and would wrap around.

This led to weird behavior; among other things, it meant a
64-bit integer with bit 31 set got sign-extended when it wasn't supposed to.

This problem was noticed because the perlbmk makerandom input was
generating negative number results.

diff -r cf6a2dce697b -r 5d1ef2e22e7c src/arch/x86/isa/microops/mediaop.isa
--- a/src/arch/x86/isa/microops/mediaop.isa     Wed Nov 04 00:47:12 2009 -0500
+++ b/src/arch/x86/isa/microops/mediaop.isa     Wed Nov 04 17:15:42 2009 -0500
@@ -1289,7 +1289,8 @@
                 int srcHiIndex = srcStart + (i + 1) * srcSizeBits - 1;
                 int srcLoIndex = srcStart + (i + 0) * srcSizeBits;
                 uint64_t argBits = bits(FpSrcReg1.uqw, srcHiIndex, srcLoIndex);
-                int64_t sArg = argBits | (0 - (argBits & (1 << srcHiIndex)));
+
+                int64_t sArg = argBits | (0 - (argBits & (1ULL << 
srcHiIndex)));
                 double arg = sArg;
 
                 if (destSize == 4) {

Attachment: cvtsi2sd
Description: Binary data

_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to