X86: Actual change that fixes div. How did that happen?
authorGabe Black <gblack@eecs.umich.edu>
Wed, 12 May 2010 07:49:12 +0000 (00:49 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 12 May 2010 07:49:12 +0000 (00:49 -0700)
src/arch/x86/isa/microops/regop.isa

index f3fc1fc59489931fba3c980637961175c95537a3..4d31a55456adee0cf8e54ca0cd9f3cd10c924cd2 100644 (file)
@@ -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 {