summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arch/x86/isa/microops/regop.isa37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/arch/x86/isa/microops/regop.isa b/src/arch/x86/isa/microops/regop.isa
index 0b1f9a96a..f3fc1fc59 100644
--- a/src/arch/x86/isa/microops/regop.isa
+++ b/src/arch/x86/isa/microops/regop.isa
@@ -612,15 +612,36 @@ let {{
//If we overshot, do nothing. This lets us unrool division loops a
//little.
if (remaining) {
- //Shift in bits from the low order portion of the dividend
- while(dividend < divisor && remaining) {
- dividend = (dividend << 1) | bits(SrcReg1, remaining - 1);
- quotient <<= 1;
- remaining--;
+ if (divisor & (ULL(1) << 63)) {
+ while (remaining && !(dividend & (ULL(1) << 63))) {
+ dividend = (dividend << 1) |
+ bits(SrcReg1, remaining - 1);
+ quotient <<= 1;
+ remaining--;
+ }
+ if (dividend & (ULL(1) << 63)) {
+ if (dividend < divisor && remaining) {
+ dividend = (dividend << 1) |
+ bits(SrcReg1, remaining - 1);
+ quotient <<= 1;
+ remaining--;
+ }
+ quotient++;
+ dividend -= divisor;
+ }
+ remainder = dividend;
+ } else {
+ //Shift in bits from the low order portion of the dividend
+ while (dividend < divisor && remaining) {
+ dividend = (dividend << 1) |
+ bits(SrcReg1, remaining - 1);
+ quotient <<= 1;
+ remaining--;
+ }
+ remainder = dividend;
+ //Do the division.
+ divide(dividend, divisor, quotient, remainder);
}
- remainder = dividend;
- //Do the division.
- divide(dividend, divisor, quotient, remainder);
}
//Keep track of how many bits there are still to pull in.
DestReg = merge(DestReg, remaining, dataSize);