Index: src/arm64/macro-assembler-arm64.cc |
diff --git a/src/arm64/macro-assembler-arm64.cc b/src/arm64/macro-assembler-arm64.cc |
index 6f52cc73b3e8d11902e131451e3fac8f5e3a72a0..d4f74d52e6e1b30921aab6544b694d1c34bcb60f 100644 |
--- a/src/arm64/macro-assembler-arm64.cc |
+++ b/src/arm64/macro-assembler-arm64.cc |
@@ -7,6 +7,7 @@ |
#if V8_TARGET_ARCH_ARM64 |
#include "src/base/bits.h" |
+#include "src/base/division-by-constant.h" |
#include "src/bootstrapper.h" |
#include "src/codegen.h" |
#include "src/cpu-profiler.h" |
@@ -5332,13 +5333,15 @@ void MacroAssembler::TruncatingDiv(Register result, |
int32_t divisor) { |
DCHECK(!AreAliased(result, dividend)); |
DCHECK(result.Is32Bits() && dividend.Is32Bits()); |
- MultiplierAndShift ms(divisor); |
- Mov(result, ms.multiplier()); |
+ base::MagicNumbersForDivision<uint32_t> mag = |
+ base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
+ Mov(result, mag.multiplier); |
Smull(result.X(), dividend, result); |
Asr(result.X(), result.X(), 32); |
- if (divisor > 0 && ms.multiplier() < 0) Add(result, result, dividend); |
- if (divisor < 0 && ms.multiplier() > 0) Sub(result, result, dividend); |
- if (ms.shift() > 0) Asr(result, result, ms.shift()); |
+ bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
+ if (divisor > 0 && neg) Add(result, result, dividend); |
+ if (divisor < 0 && !neg && mag.multiplier > 0) Sub(result, result, dividend); |
+ if (mag.shift > 0) Asr(result, result, mag.shift); |
Add(result, result, Operand(dividend, LSR, 31)); |
} |