Revision: 21313
Author: [email protected]
Date: Wed May 14 14:34:37 2014 UTC
Log: Fix FlooringDivByPowerOf2I on ARM/ARM64
Fix for divisor=1, found during code inspection. We can't hit this bug, due
to
HDiv::Canonicalize() discarding the operation, but it might avoid a future
bug
hunt. Patch also includes a small tidying of the ARM64 code.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/280883003
http://code.google.com/p/v8/source/detail?r=21313
Modified:
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Mon May 12
13:47:01 2014 UTC
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed May 14
14:34:37 2014 UTC
@@ -1434,10 +1434,15 @@
Register dividend = ToRegister(instr->dividend());
Register result = ToRegister(instr->result());
int32_t divisor = instr->divisor();
+
+ // If the divisor is 1, return the dividend.
+ if (divisor == 1) {
+ __ Move(result, dividend);
+ return;
+ }
// If the divisor is positive, things are easy: There can be no deopts
and we
// can simply do an arithmetic right shift.
- if (divisor == 1) return;
int32_t shift = WhichPowerOf2Abs(divisor);
if (divisor > 1) {
__ mov(result, Operand(dividend, ASR, shift));
=======================================
--- /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Wed May 14
14:01:29 2014 UTC
+++ /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Wed May 14
14:34:37 2014 UTC
@@ -3878,10 +3878,15 @@
Register dividend = ToRegister32(instr->dividend());
Register result = ToRegister32(instr->result());
int32_t divisor = instr->divisor();
+
+ // If the divisor is 1, return the dividend.
+ if (divisor == 1) {
+ __ Mov(result, dividend, kDiscardForSameWReg);
+ return;
+ }
// If the divisor is positive, things are easy: There can be no deopts
and we
// can simply do an arithmetic right shift.
- if (divisor == 1) return;
int32_t shift = WhichPowerOf2Abs(divisor);
if (divisor > 1) {
__ Mov(result, Operand(dividend, ASR, shift));
@@ -3906,14 +3911,8 @@
return;
}
- // Using a conditional data processing instruction would need 1 more
register.
- Label not_kmin_int, done;
- __ B(vc, ¬_kmin_int);
- __ Mov(result, kMinInt / divisor);
- __ B(&done);
- __ bind(¬_kmin_int);
- __ Mov(result, Operand(dividend, ASR, shift));
- __ bind(&done);
+ __ Asr(result, dividend, shift);
+ __ Csel(result, result, kMinInt / divisor, vc);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.