diff options
-rw-r--r-- | src/arch/x86/isa/microops/mediaop.isa | 3 | ||||
-rw-r--r-- | src/arch/x86/isa/microops/regop.isa | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/arch/x86/isa/microops/mediaop.isa b/src/arch/x86/isa/microops/mediaop.isa index 900c166f8..9a2707b59 100644 --- a/src/arch/x86/isa/microops/mediaop.isa +++ b/src/arch/x86/isa/microops/mediaop.isa @@ -1294,7 +1294,8 @@ let {{ int srcLoIndex = srcStart + (i + 0) * srcSizeBits; uint64_t argBits = bits(FpSrcReg1.uqw, srcHiIndex, srcLoIndex); - int64_t sArg = argBits | (0 - (argBits & (ULL(1) << srcHiIndex))); + int64_t sArg = argBits | + (0 - (argBits & (ULL(1) << (srcSizeBits - 1)))); double arg = sArg; if (destSize == 4) { diff --git a/src/arch/x86/isa/microops/regop.isa b/src/arch/x86/isa/microops/regop.isa index f3fc1fc59..4d31a5545 100644 --- a/src/arch/x86/isa/microops/regop.isa +++ b/src/arch/x86/isa/microops/regop.isa @@ -620,14 +620,18 @@ let {{ remaining--; } if (dividend & (ULL(1) << 63)) { + bool highBit = false; if (dividend < divisor && remaining) { + highBit = true; dividend = (dividend << 1) | bits(SrcReg1, remaining - 1); quotient <<= 1; remaining--; } - quotient++; - dividend -= divisor; + if (highBit || divisor <= dividend) { + quotient++; + dividend -= divisor; + } } remainder = dividend; } else { |