Index: src/arm/macro-assembler-arm.cc |
diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc |
index 619c9446009e54f4323b5ba3af53eb671f66fc33..d16d5b63561f987a8c3c7a9f7f328430ddba4dba 100644 |
--- a/src/arm/macro-assembler-arm.cc |
+++ b/src/arm/macro-assembler-arm.cc |
@@ -9,6 +9,7 @@ |
#if V8_TARGET_ARCH_ARM |
#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" |
@@ -4093,16 +4094,18 @@ void MacroAssembler::TruncatingDiv(Register result, |
DCHECK(!dividend.is(result)); |
DCHECK(!dividend.is(ip)); |
DCHECK(!result.is(ip)); |
- MultiplierAndShift ms(divisor); |
- mov(ip, Operand(ms.multiplier())); |
+ base::MagicNumbersForDivision<uint32_t> mag = |
+ base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
+ mov(ip, Operand(mag.multiplier)); |
smull(ip, result, dividend, ip); |
- if (divisor > 0 && ms.multiplier() < 0) { |
+ bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
+ if (divisor > 0 && neg) { |
add(result, result, Operand(dividend)); |
} |
- if (divisor < 0 && ms.multiplier() > 0) { |
+ if (divisor < 0 && !neg && mag.multiplier > 0) { |
sub(result, result, Operand(dividend)); |
} |
- if (ms.shift() > 0) mov(result, Operand(result, ASR, ms.shift())); |
+ if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
add(result, result, Operand(dividend, LSR, 31)); |
} |