Handle flooring division in LCodeGen::DoDivByConstI on ARM, too.

We should really split up the Lithium instruction, but this will be
done in some future cleanup CL.

Removed some "const"s for local variables on the way, they don't really
help us much and just clutter up the code.

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/196603004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19850 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 87e77085
...@@ -1365,9 +1365,9 @@ void LCodeGen::DoDivByConstI(LDivByConstI* instr) { ...@@ -1365,9 +1365,9 @@ void LCodeGen::DoDivByConstI(LDivByConstI* instr) {
void LCodeGen::DoDivI(LDivI* instr) { void LCodeGen::DoDivI(LDivI* instr) {
HBinaryOperation* hdiv = instr->hydrogen(); HBinaryOperation* hdiv = instr->hydrogen();
const Register left = ToRegister(instr->left()); Register left = ToRegister(instr->left());
const Register right = ToRegister(instr->right()); Register right = ToRegister(instr->right());
const Register result = ToRegister(instr->result()); Register result = ToRegister(instr->result());
// Check for x / 0. // Check for x / 0.
if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
...@@ -1402,17 +1402,9 @@ void LCodeGen::DoDivI(LDivI* instr) { ...@@ -1402,17 +1402,9 @@ void LCodeGen::DoDivI(LDivI* instr) {
if (CpuFeatures::IsSupported(SUDIV)) { if (CpuFeatures::IsSupported(SUDIV)) {
CpuFeatureScope scope(masm(), SUDIV); CpuFeatureScope scope(masm(), SUDIV);
__ sdiv(result, left, right); __ sdiv(result, left, right);
if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
// Compute remainder and deopt if it's not zero.
const Register remainder = scratch0();
__ mls(remainder, result, right, left);
__ cmp(remainder, Operand::Zero());
DeoptimizeIf(ne, instr->environment());
}
} else { } else {
const DoubleRegister vleft = ToDoubleRegister(instr->temp()); DoubleRegister vleft = ToDoubleRegister(instr->temp());
const DoubleRegister vright = double_scratch0(); DoubleRegister vright = double_scratch0();
__ vmov(double_scratch0().low(), left); __ vmov(double_scratch0().low(), left);
__ vcvt_f64_s32(vleft, double_scratch0().low()); __ vcvt_f64_s32(vleft, double_scratch0().low());
__ vmov(double_scratch0().low(), right); __ vmov(double_scratch0().low(), right);
...@@ -1420,14 +1412,23 @@ void LCodeGen::DoDivI(LDivI* instr) { ...@@ -1420,14 +1412,23 @@ void LCodeGen::DoDivI(LDivI* instr) {
__ vdiv(vleft, vleft, vright); // vleft now contains the result. __ vdiv(vleft, vleft, vright); // vleft now contains the result.
__ vcvt_s32_f64(double_scratch0().low(), vleft); __ vcvt_s32_f64(double_scratch0().low(), vleft);
__ vmov(result, double_scratch0().low()); __ vmov(result, double_scratch0().low());
}
if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { if (hdiv->IsMathFloorOfDiv()) {
// Deopt if exact conversion to integer was not possible. Label done;
// Use vright as scratch register. Register remainder = scratch0();
__ vcvt_f64_s32(double_scratch0(), double_scratch0().low()); __ mls(remainder, result, right, left);
__ VFPCompareAndSetFlags(vleft, double_scratch0()); __ cmp(remainder, Operand::Zero());
DeoptimizeIf(ne, instr->environment()); __ b(eq, &done);
} __ eor(remainder, remainder, Operand(right));
__ add(result, result, Operand(remainder, ASR, 31));
__ bind(&done);
} else if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
// Compute remainder and deopt if it's not zero.
Register remainder = scratch0();
__ mls(remainder, result, right, left);
__ cmp(remainder, Operand::Zero());
DeoptimizeIf(ne, instr->environment());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment