From 9d03e75c33a286f58578088c39c556cfb360074a Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sat, 6 May 2006 14:40:40 +0000 Subject: [PATCH] Fix for 32-bit mode, as per comment. git-svn-id: svn://svn.valgrind.org/vex/trunk@1610 --- VEX/priv/host-ppc/hdefs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/VEX/priv/host-ppc/hdefs.c b/VEX/priv/host-ppc/hdefs.c index 801997a327..5498a7b85d 100644 --- a/VEX/priv/host-ppc/hdefs.c +++ b/VEX/priv/host-ppc/hdefs.c @@ -2468,6 +2468,16 @@ static UChar* mkLoadImm ( UChar* p, UInt r_dst, ULong imm, Bool mode64 ) { vassert(r_dst < 0x20); + if (!mode64) { + /* In 32-bit mode, make sure the top 32 bits of imm are a sign + extension of the bottom 32 bits, so that the range tests + below work correctly. */ + UInt u32 = (UInt)imm; + Int s32 = (Int)u32; + Long s64 = (Long)s32; + imm = (ULong)s64; + } + if (imm >= 0xFFFFFFFFFFFF8000ULL || imm < 0x8000) { // sign-extendable from 16 bits -- 2.47.2