Revision: 19796
Author: [email protected]
Date: Tue Mar 11 11:57:27 2014 UTC
Log: Cleanup some of the range uses in ModI/DivI.
BUG=v8:3204
LOG=y
[email protected]
Review URL: https://codereview.chromium.org/191293013
http://code.google.com/p/v8/source/detail?r=19796
Modified:
/branches/bleeding_edge/src/a64/lithium-a64.cc
/branches/bleeding_edge/src/a64/lithium-a64.h
/branches/bleeding_edge/src/a64/lithium-codegen-a64.cc
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.h
=======================================
--- /branches/bleeding_edge/src/a64/lithium-a64.cc Mon Mar 10 10:39:17 2014
UTC
+++ /branches/bleeding_edge/src/a64/lithium-a64.cc Tue Mar 11 11:57:27 2014
UTC
@@ -1374,16 +1374,15 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor));
- bool can_deopt =
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- (instr->CheckFlag(HValue::kCanOverflow) &&
- instr->left()->RangeCanInclude(kMinInt) && divisor == -1) ||
+ LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
+ dividend, divisor));
+ if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
(!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
- divisor != 1 && divisor != -1);
- return can_deopt ? AssignEnvironment(result) : result;
+ divisor != 1 && divisor != -1)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1393,16 +1392,16 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- bool truncating =
instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32);
- LOperand* temp = truncating ? NULL : TempRegister();
- LInstruction* result =
- DefineAsRegister(new(zone()) LDivByConstI(dividend, divisor, temp));
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- !truncating;
- return can_deopt ? AssignEnvironment(result) : result;
+ LOperand* temp =
instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
+ ? NULL : TempRegister();
+ LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI(
+ dividend, divisor, temp));
+ if (divisor == 0 ||
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1760,8 +1759,7 @@
DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend,
divisor));
bool can_deopt =
divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0);
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
return can_deopt ? AssignEnvironment(result) : result;
}
@@ -1812,12 +1810,12 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegisterAtStart(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor));
- bool can_deopt =
- instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative();
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
+ dividend, divisor));
+ if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1828,13 +1826,12 @@
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
LOperand* temp = TempRegister();
- LInstruction* result =
- DefineAsRegister(new(zone()) LModByConstI(dividend, divisor, temp));
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative());
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineAsRegister(new(zone()) LModByConstI(
+ dividend, divisor, temp));
+ if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1844,12 +1841,12 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
LOperand* divisor = UseRegister(instr->right());
- LInstruction* result =
- DefineAsRegister(new(zone()) LModI(dividend, divisor));
- bool can_deopt = (instr->right()->CanBeZero() ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative() &&
instr->CanBeZero()));
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineAsRegister(new(zone()) LModI(dividend,
divisor));
+ if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/bleeding_edge/src/a64/lithium-a64.h Mon Mar 10 10:39:17 2014
UTC
+++ /branches/bleeding_edge/src/a64/lithium-a64.h Tue Mar 11 11:57:27 2014
UTC
@@ -1334,8 +1334,6 @@
LOperand* left() { return inputs_[0]; }
LOperand* right() { return inputs_[1]; }
LOperand* temp() { return temps_[0]; }
-
- bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
=======================================
--- /branches/bleeding_edge/src/a64/lithium-codegen-a64.cc Mon Mar 10
16:25:15 2014 UTC
+++ /branches/bleeding_edge/src/a64/lithium-codegen-a64.cc Tue Mar 11
11:57:27 2014 UTC
@@ -2607,14 +2607,12 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ Cmp(dividend, 0);
DeoptimizeIf(eq, instr->environment());
}
// Check for (kMinInt / -1).
- if (hdiv->CheckFlag(HValue::kCanOverflow) &&
- hdiv->left()->RangeCanInclude(kMinInt) && divisor == -1) {
+ if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
__ Cmp(dividend, kMinInt);
DeoptimizeIf(eq, instr->environment());
}
@@ -2657,8 +2655,7 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
DeoptimizeIfZero(dividend, instr->environment());
}
@@ -2678,16 +2675,16 @@
void LCodeGen::DoDivI(LDivI* instr) {
+ HBinaryOperation* hdiv = instr->hydrogen();
Register dividend = ToRegister32(instr->left());
Register divisor = ToRegister32(instr->right());
Register result = ToRegister32(instr->result());
- HValue* hdiv = instr->hydrogen_value();
// Issue the division first, and then check for any deopt cases whilst
the
// result is computed.
__ Sdiv(result, dividend, divisor);
- if (hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
+ if (hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
ASSERT_EQ(NULL, instr->temp());
return;
}
@@ -3895,8 +3892,7 @@
// Check for (0 / -x) that will produce negative zero.
HMathFloorOfDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ Cmp(dividend, 0);
DeoptimizeIf(eq, instr->environment());
}
@@ -4184,8 +4180,7 @@
// Check for negative zero.
HMod* hmod = instr->hydrogen();
- if (hmod->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hmod->left()->CanBeNegative()) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label remainder_not_zero;
__ Cbnz(result, &remainder_not_zero);
DeoptimizeIfNegative(dividend, instr->environment());
@@ -4202,7 +4197,7 @@
Label deopt, done;
// modulo = dividend - quotient * divisor
__ Sdiv(result, dividend, divisor);
- if (instr->hydrogen()->right()->CanBeZero()) {
+ if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
// Combine the deoptimization sites.
Label ok;
__ Cbnz(divisor, &ok);
@@ -4211,9 +4206,7 @@
__ Bind(&ok);
}
__ Msub(result, result, divisor, dividend);
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->hydrogen()->left()->CanBeNegative() &&
- instr->hydrogen()->CanBeZero()) {
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
__ Cbnz(result, &done);
if (deopt.is_bound()) { // TODO(all) This is a hack, remove this...
__ Tbnz(dividend, kWSignBit, &deopt);
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Mon Mar 10 10:39:17 2014
UTC
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Tue Mar 11 11:57:27 2014
UTC
@@ -1244,16 +1244,15 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor));
- bool can_deopt =
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- (instr->CheckFlag(HValue::kCanOverflow) &&
- instr->left()->RangeCanInclude(kMinInt) && divisor == -1) ||
+ LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
+ dividend, divisor));
+ if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
(!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
- divisor != 1 && divisor != -1);
- return can_deopt ? AssignEnvironment(result) : result;
+ divisor != 1 && divisor != -1)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1263,14 +1262,14 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineAsRegister(new(zone()) LDivByConstI(dividend, divisor));
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32);
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI(
+ dividend, divisor));
+ if (divisor == 0 ||
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1326,8 +1325,7 @@
DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend,
divisor));
bool can_deopt =
divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0);
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
return can_deopt ? AssignEnvironment(result) : result;
}
@@ -1349,12 +1347,12 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegisterAtStart(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor));
- bool can_deopt =
- instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative();
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
+ dividend, divisor));
+ if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1364,13 +1362,12 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineAsRegister(new(zone()) LModByConstI(dividend, divisor));
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative());
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineAsRegister(new(zone()) LModByConstI(
+ dividend, divisor));
+ if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1378,32 +1375,17 @@
ASSERT(instr->representation().IsSmiOrInteger32());
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (CpuFeatures::IsSupported(SUDIV)) {
- LOperand* dividend = UseRegister(instr->left());
- LOperand* divisor = UseRegister(instr->right());
- LInstruction* result =
- DefineAsRegister(new(zone()) LModI(dividend, divisor, NULL, NULL));
- bool can_deopt = (instr->right()->CanBeZero() ||
- (instr->left()->RangeCanInclude(kMinInt) &&
- instr->right()->RangeCanInclude(-1) &&
- instr->CheckFlag(HValue::kBailoutOnMinusZero)) ||
- (instr->left()->CanBeNegative() &&
- instr->CanBeZero() &&
- instr->CheckFlag(HValue::kBailoutOnMinusZero)));
- return can_deopt ? AssignEnvironment(result) : result;
- } else {
- LOperand* dividend = UseRegister(instr->left());
- LOperand* divisor = UseRegister(instr->right());
- LOperand* temp = FixedTemp(d10);
- LOperand* temp2 = FixedTemp(d11);
- LInstruction* result =
- DefineAsRegister(new(zone()) LModI(dividend, divisor, temp,
temp2));
- bool can_deopt = (instr->right()->CanBeZero() ||
- (instr->left()->CanBeNegative() &&
- instr->CanBeZero() &&
- instr->CheckFlag(HValue::kBailoutOnMinusZero)));
- return can_deopt ? AssignEnvironment(result) : result;
+ LOperand* dividend = UseRegister(instr->left());
+ LOperand* divisor = UseRegister(instr->right());
+ LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d10);
+ LOperand* temp2 = CpuFeatures::IsSupported(SUDIV) ? NULL :
FixedTemp(d11);
+ LInstruction* result = DefineAsRegister(new(zone()) LModI(
+ dividend, divisor, temp, temp2));
+ if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
}
+ return result;
}
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Mon Mar 10 10:39:17 2014
UTC
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Tue Mar 11 11:57:27 2014
UTC
@@ -724,8 +724,6 @@
LOperand* left() { return inputs_[0]; }
LOperand* right() { return inputs_[1]; }
LOperand* temp() { return temps_[0]; }
-
- bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Mon Mar 10
13:23:28 2014 UTC
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Mar 11
11:57:27 2014 UTC
@@ -1163,8 +1163,7 @@
// Check for negative zero.
HMod* hmod = instr->hydrogen();
- if (hmod->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hmod->left()->CanBeNegative()) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label remainder_not_zero;
__ b(ne, &remainder_not_zero);
__ cmp(dividend, Operand::Zero());
@@ -1176,8 +1175,6 @@
void LCodeGen::DoModI(LModI* instr) {
HMod* hmod = instr->hydrogen();
- HValue* left = hmod->left();
- HValue* right = hmod->right();
if (CpuFeatures::IsSupported(SUDIV)) {
CpuFeatureScope scope(masm(), SUDIV);
@@ -1188,14 +1185,14 @@
Label done;
// Check for x % 0, sdiv might signal an exception. We have to deopt
in this
// case because we can't return a NaN.
- if (right->CanBeZero()) {
+ if (hmod->CheckFlag(HValue::kCanBeDivByZero)) {
__ cmp(right_reg, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
// Check for kMinInt % -1, sdiv will return kMinInt, which is not what
we
// want. We have to deopt if we care about -0, because we can't return
that.
- if (left->RangeCanInclude(kMinInt) && right->RangeCanInclude(-1)) {
+ if (hmod->CheckFlag(HValue::kCanOverflow)) {
Label no_overflow_possible;
__ cmp(left_reg, Operand(kMinInt));
__ b(ne, &no_overflow_possible);
@@ -1218,9 +1215,7 @@
__ mls(result_reg, result_reg, right_reg, left_reg);
// If we care about -0, test if the dividend is <0 and the result is 0.
- if (left->CanBeNegative() &&
- hmod->CanBeZero() &&
- hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
__ cmp(result_reg, Operand::Zero());
__ b(ne, &done);
__ cmp(left_reg, Operand::Zero());
@@ -1247,7 +1242,7 @@
Label done;
// Check for x % 0, we have to deopt in this case because we can't
return a
// NaN.
- if (right->CanBeZero()) {
+ if (hmod->CheckFlag(HValue::kCanBeDivByZero)) {
__ cmp(right_reg, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
@@ -1276,9 +1271,7 @@
__ sub(result_reg, left_reg, scratch, SetCC);
// If we care about -0, test if the dividend is <0 and the result is 0.
- if (left->CanBeNegative() &&
- hmod->CanBeZero() &&
- hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
__ b(ne, &done);
__ cmp(left_reg, Operand::Zero());
DeoptimizeIf(mi, instr->environment());
@@ -1297,14 +1290,12 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ cmp(dividend, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
// Check for (kMinInt / -1).
- if (hdiv->CheckFlag(HValue::kCanOverflow) &&
- hdiv->left()->RangeCanInclude(kMinInt) && divisor == -1) {
+ if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
__ cmp(dividend, Operand(kMinInt));
DeoptimizeIf(eq, instr->environment());
}
@@ -1347,8 +1338,7 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ cmp(dividend, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
@@ -1367,18 +1357,19 @@
void LCodeGen::DoDivI(LDivI* instr) {
+ HBinaryOperation* hdiv = instr->hydrogen();
const Register left = ToRegister(instr->left());
const Register right = ToRegister(instr->right());
const Register result = ToRegister(instr->result());
// Check for x / 0.
- if (instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) {
+ if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
__ cmp(right, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
// Check for (0 / -x) that will produce negative zero.
- if (instr->hydrogen_value()->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label positive;
if (!instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) {
// Do the test only if it hadn't be done above.
@@ -1391,10 +1382,9 @@
}
// Check for (kMinInt / -1).
- if (instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow) &&
+ if (hdiv->CheckFlag(HValue::kCanOverflow) &&
(!CpuFeatures::IsSupported(SUDIV) ||
- !instr->hydrogen_value()->CheckFlag(
- HValue::kAllUsesTruncatingToInt32))) {
+ !hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
// We don't need to check for overflow when truncating with sdiv
// support because, on ARM, sdiv kMinInt, -1 -> kMinInt.
__ cmp(left, Operand(kMinInt));
@@ -1406,8 +1396,7 @@
CpuFeatureScope scope(masm(), SUDIV);
__ sdiv(result, left, right);
- if (!instr->hydrogen_value()->CheckFlag(
- HInstruction::kAllUsesTruncatingToInt32)) {
+ if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
// Compute remainder and deopt if it's not zero.
const Register remainder = scratch0();
__ mls(remainder, result, right, left);
@@ -1425,8 +1414,7 @@
__ vcvt_s32_f64(double_scratch0().low(), vleft);
__ vmov(result, double_scratch0().low());
- if (!instr->hydrogen_value()->CheckFlag(
- HInstruction::kAllUsesTruncatingToInt32)) {
+ if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
// Deopt if exact conversion to integer was not possible.
// Use vright as scratch register.
__ vcvt_f64_s32(double_scratch0(), double_scratch0().low());
@@ -1511,8 +1499,7 @@
// Check for (0 / -x) that will produce negative zero.
HMathFloorOfDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ cmp(dividend, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Tue Mar 11 11:36:55
2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Tue Mar 11 11:57:27
2014 UTC
@@ -855,7 +855,6 @@
// TODO(svenpanne) We should really use the null object pattern here.
bool HasRange() const { return range_ != NULL; }
bool CanBeNegative() const { return !HasRange() ||
range()->CanBeNegative(); }
- bool CanBeZero() const { return !HasRange() || range()->CanBeZero(); }
bool RangeCanInclude(int value) const {
return !HasRange() || range()->Includes(value);
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon Mar 10
10:39:17 2014 UTC
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Mar 11
11:57:27 2014 UTC
@@ -1421,8 +1421,7 @@
// Check for negative zero.
HMod* hmod = instr->hydrogen();
- if (hmod->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hmod->left()->CanBeNegative()) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label remainder_not_zero;
__ j(not_zero, &remainder_not_zero, Label::kNear);
__ cmp(dividend, Immediate(0));
@@ -1434,8 +1433,6 @@
void LCodeGen::DoModI(LModI* instr) {
HMod* hmod = instr->hydrogen();
- HValue* left = hmod->left();
- HValue* right = hmod->right();
Register left_reg = ToRegister(instr->left());
ASSERT(left_reg.is(eax));
@@ -1448,14 +1445,14 @@
Label done;
// Check for x % 0, idiv would signal a divide error. We have to
// deopt in this case because we can't return a NaN.
- if (right->CanBeZero()) {
+ if (hmod->CheckFlag(HValue::kCanBeDivByZero)) {
__ test(right_reg, Operand(right_reg));
DeoptimizeIf(zero, instr->environment());
}
// Check for kMinInt % -1, idiv would signal a divide error. We
// have to deopt if we care about -0, because we can't return that.
- if (left->RangeCanInclude(kMinInt) && right->RangeCanInclude(-1)) {
+ if (hmod->CheckFlag(HValue::kCanOverflow)) {
Label no_overflow_possible;
__ cmp(left_reg, kMinInt);
__ j(not_equal, &no_overflow_possible, Label::kNear);
@@ -1474,9 +1471,7 @@
__ cdq();
// If we care about -0, test if the dividend is <0 and the result is 0.
- if (left->CanBeNegative() &&
- hmod->CanBeZero() &&
- hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label positive_left;
__ test(left_reg, Operand(left_reg));
__ j(not_sign, &positive_left, Label::kNear);
@@ -1500,14 +1495,12 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ test(dividend, dividend);
DeoptimizeIf(zero, instr->environment());
}
// Check for (kMinInt / -1).
- if (hdiv->CheckFlag(HValue::kCanOverflow) &&
- hdiv->left()->RangeCanInclude(kMinInt) && divisor == -1) {
+ if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
__ cmp(dividend, kMinInt);
DeoptimizeIf(zero, instr->environment());
}
@@ -1543,8 +1536,7 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ test(dividend, dividend);
DeoptimizeIf(zero, instr->environment());
}
@@ -1565,6 +1557,7 @@
void LCodeGen::DoDivI(LDivI* instr) {
+ HBinaryOperation* hdiv = instr->hydrogen();
Register dividend = ToRegister(instr->left());
Register divisor = ToRegister(instr->right());
Register remainder = ToRegister(instr->temp());
@@ -1576,7 +1569,6 @@
ASSERT(!divisor.is(edx));
// Check for x / 0.
- HBinaryOperation* hdiv = instr->hydrogen();
if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
__ test(divisor, divisor);
DeoptimizeIf(zero, instr->environment());
@@ -1606,7 +1598,7 @@
__ cdq();
__ idiv(divisor);
- if (instr->is_flooring()) {
+ if (hdiv->IsMathFloorOfDiv()) {
Label done;
__ test(remainder, remainder);
__ j(zero, &done, Label::kNear);
@@ -1614,8 +1606,7 @@
__ sar(remainder, 31);
__ add(result, remainder);
__ bind(&done);
- } else if (!instr->hydrogen()->CheckFlag(
- HInstruction::kAllUsesTruncatingToInt32)) {
+ } else if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
// Deoptimize if remainder is not 0.
__ test(remainder, remainder);
DeoptimizeIf(not_zero, instr->environment());
@@ -1672,8 +1663,7 @@
// Check for (0 / -x) that will produce negative zero.
HMathFloorOfDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ test(dividend, dividend);
DeoptimizeIf(zero, instr->environment());
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Mon Mar 10 10:39:17
2014 UTC
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Mar 11 11:57:27
2014 UTC
@@ -1327,16 +1327,15 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor));
- bool can_deopt =
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- (instr->CheckFlag(HValue::kCanOverflow) &&
- instr->left()->RangeCanInclude(kMinInt) && divisor == -1) ||
+ LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
+ dividend, divisor));
+ if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
(!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
- divisor != 1 && divisor != -1);
- return can_deopt ? AssignEnvironment(result) : result;
+ divisor != 1 && divisor != -1)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1348,15 +1347,14 @@
int32_t divisor = instr->right()->GetInteger32Constant();
LOperand* temp1 = FixedTemp(eax);
LOperand* temp2 = FixedTemp(edx);
- LInstruction* result =
- DefineFixed(
- new(zone()) LDivByConstI(dividend, divisor, temp1, temp2), edx);
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32);
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineFixed(new(zone()) LDivByConstI(
+ dividend, divisor, temp1, temp2), edx);
+ if (divisor == 0 ||
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1367,9 +1365,16 @@
LOperand* dividend = UseFixed(instr->left(), eax);
LOperand* divisor = UseRegister(instr->right());
LOperand* temp = FixedTemp(edx);
- LInstruction* result =
- DefineFixed(new(zone()) LDivI(dividend, divisor, temp), eax);
- return AssignEnvironment(result);
+ LInstruction* result = DefineFixed(new(zone()) LDivI(
+ dividend, divisor, temp), eax);
+ if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
+ instr->CheckFlag(HValue::kCanOverflow) ||
+ (!instr->IsMathFloorOfDiv() &&
+ !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1418,8 +1423,7 @@
edx);
bool can_deopt =
divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0);
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
return can_deopt ? AssignEnvironment(result) : result;
}
@@ -1441,12 +1445,12 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegisterAtStart(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor));
- bool can_deopt =
- instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative();
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
+ dividend, divisor));
+ if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1458,14 +1462,12 @@
int32_t divisor = instr->right()->GetInteger32Constant();
LOperand* temp1 = FixedTemp(eax);
LOperand* temp2 = FixedTemp(edx);
- LInstruction* result =
- DefineFixed(
- new(zone()) LModByConstI(dividend, divisor, temp1, temp2), eax);
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative());
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineFixed(new(zone()) LModByConstI(
+ dividend, divisor, temp1, temp2), eax);
+ if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1476,16 +1478,13 @@
LOperand* dividend = UseFixed(instr->left(), eax);
LOperand* divisor = UseRegister(instr->right());
LOperand* temp = FixedTemp(edx);
- LInstruction* result =
- DefineFixed(new(zone()) LModI(dividend, divisor, temp), edx);
- bool can_deopt = (instr->right()->CanBeZero() ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(kMinInt) &&
- instr->right()->RangeCanInclude(-1)) ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative() &&
- instr->CanBeZero()));
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineFixed(new(zone()) LModI(
+ dividend, divisor, temp), edx);
+ if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Mon Mar 10 10:39:17
2014 UTC
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Tue Mar 11 11:57:27
2014 UTC
@@ -755,8 +755,6 @@
LOperand* left() { return inputs_[0]; }
LOperand* right() { return inputs_[1]; }
LOperand* temp() { return temps_[0]; }
-
- bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Mon Mar 10
10:39:17 2014 UTC
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Mar 11
11:57:27 2014 UTC
@@ -1036,8 +1036,7 @@
// Check for negative zero.
HMod* hmod = instr->hydrogen();
- if (hmod->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hmod->left()->CanBeNegative()) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label remainder_not_zero;
__ j(not_zero, &remainder_not_zero, Label::kNear);
__ cmpl(dividend, Immediate(0));
@@ -1048,12 +1047,7 @@
void LCodeGen::DoModI(LModI* instr) {
- if (instr->hydrogen()->RightIsPowerOf2()) {
- return DoModByPowerOf2I(reinterpret_cast<LModByPowerOf2I*>(instr));
- }
HMod* hmod = instr->hydrogen();
- HValue* left = hmod->left();
- HValue* right = hmod->right();
Register left_reg = ToRegister(instr->left());
ASSERT(left_reg.is(rax));
@@ -1066,14 +1060,14 @@
Label done;
// Check for x % 0, idiv would signal a divide error. We have to
// deopt in this case because we can't return a NaN.
- if (right->CanBeZero()) {
+ if (hmod->CheckFlag(HValue::kCanBeDivByZero)) {
__ testl(right_reg, right_reg);
DeoptimizeIf(zero, instr->environment());
}
// Check for kMinInt % -1, idiv would signal a divide error. We
// have to deopt if we care about -0, because we can't return that.
- if (left->RangeCanInclude(kMinInt) && right->RangeCanInclude(-1)) {
+ if (hmod->CheckFlag(HValue::kCanOverflow)) {
Label no_overflow_possible;
__ cmpl(left_reg, Immediate(kMinInt));
__ j(not_zero, &no_overflow_possible, Label::kNear);
@@ -1093,9 +1087,7 @@
__ cdq();
// If we care about -0, test if the dividend is <0 and the result is 0.
- if (left->CanBeNegative() &&
- hmod->CanBeZero() &&
- hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label positive_left;
__ testl(left_reg, left_reg);
__ j(not_sign, &positive_left, Label::kNear);
@@ -1159,8 +1151,7 @@
// Check for (0 / -x) that will produce negative zero.
HMathFloorOfDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ testl(dividend, dividend);
DeoptimizeIf(zero, instr->environment());
}
@@ -1178,14 +1169,12 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ testl(dividend, dividend);
DeoptimizeIf(zero, instr->environment());
}
// Check for (kMinInt / -1).
- if (hdiv->CheckFlag(HValue::kCanOverflow) &&
- hdiv->left()->RangeCanInclude(kMinInt) && divisor == -1) {
+ if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
__ cmpl(dividend, Immediate(kMinInt));
DeoptimizeIf(zero, instr->environment());
}
@@ -1221,8 +1210,7 @@
// Check for (0 / -x) that will produce negative zero.
HDiv* hdiv = instr->hydrogen();
- if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) &&
- hdiv->left()->RangeCanInclude(0) && divisor < 0) {
+ if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
__ testl(dividend, dividend);
DeoptimizeIf(zero, instr->environment());
}
@@ -1243,6 +1231,7 @@
void LCodeGen::DoDivI(LDivI* instr) {
+ HBinaryOperation* hdiv = instr->hydrogen();
Register dividend = ToRegister(instr->left());
Register divisor = ToRegister(instr->right());
Register remainder = ToRegister(instr->temp());
@@ -1254,7 +1243,6 @@
ASSERT(!divisor.is(rdx));
// Check for x / 0.
- HBinaryOperation* hdiv = instr->hydrogen();
if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
__ testl(divisor, divisor);
DeoptimizeIf(zero, instr->environment());
@@ -1284,7 +1272,7 @@
__ cdq();
__ idivl(divisor);
- if (instr->is_flooring()) {
+ if (hdiv->IsMathFloorOfDiv()) {
Label done;
__ testl(remainder, remainder);
__ j(zero, &done, Label::kNear);
@@ -1292,8 +1280,7 @@
__ sarl(remainder, Immediate(31));
__ addl(result, remainder);
__ bind(&done);
- } else if (!instr->hydrogen()->CheckFlag(
- HInstruction::kAllUsesTruncatingToInt32)) {
+ } else if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
// Deoptimize if remainder is not 0.
__ testl(remainder, remainder);
DeoptimizeIf(not_zero, instr->environment());
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Mon Mar 10 10:39:17 2014
UTC
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Tue Mar 11 11:57:27 2014
UTC
@@ -1248,16 +1248,15 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegister(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor));
- bool can_deopt =
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- (instr->CheckFlag(HValue::kCanOverflow) &&
- instr->left()->RangeCanInclude(kMinInt) && divisor == -1) ||
+ LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
+ dividend, divisor));
+ if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
(!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
- divisor != 1 && divisor != -1);
- return can_deopt ? AssignEnvironment(result) : result;
+ divisor != 1 && divisor != -1)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1269,15 +1268,14 @@
int32_t divisor = instr->right()->GetInteger32Constant();
LOperand* temp1 = FixedTemp(rax);
LOperand* temp2 = FixedTemp(rdx);
- LInstruction* result =
- DefineFixed(
- new(zone()) LDivByConstI(dividend, divisor, temp1, temp2), rdx);
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0) ||
- !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32);
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineFixed(new(zone()) LDivByConstI(
+ dividend, divisor, temp1, temp2), rdx);
+ if (divisor == 0 ||
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
+ !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1288,9 +1286,16 @@
LOperand* dividend = UseFixed(instr->left(), rax);
LOperand* divisor = UseRegister(instr->right());
LOperand* temp = FixedTemp(rdx);
- LInstruction* result =
- DefineFixed(new(zone()) LDivI(dividend, divisor, temp), rax);
- return AssignEnvironment(result);
+ LInstruction* result = DefineFixed(new(zone()) LDivI(
+ dividend, divisor, temp), rax);
+ if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
+ instr->CheckFlag(HValue::kCanOverflow) ||
+ (!instr->IsMathFloorOfDiv() &&
+ !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1339,8 +1344,7 @@
rdx);
bool can_deopt =
divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(0) && divisor < 0);
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
return can_deopt ? AssignEnvironment(result) : result;
}
@@ -1362,12 +1366,12 @@
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* dividend = UseRegisterAtStart(instr->left());
int32_t divisor = instr->right()->GetInteger32Constant();
- LInstruction* result =
- DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor));
- bool can_deopt =
- instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative();
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
+ dividend, divisor));
+ if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1379,14 +1383,12 @@
int32_t divisor = instr->right()->GetInteger32Constant();
LOperand* temp1 = FixedTemp(rax);
LOperand* temp2 = FixedTemp(rdx);
- LInstruction* result =
- DefineFixed(
- new(zone()) LModByConstI(dividend, divisor, temp1, temp2), rax);
- bool can_deopt =
- divisor == 0 ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative());
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineFixed(new(zone()) LModByConstI(
+ dividend, divisor, temp1, temp2), rax);
+ if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
@@ -1397,16 +1399,13 @@
LOperand* dividend = UseFixed(instr->left(), rax);
LOperand* divisor = UseRegister(instr->right());
LOperand* temp = FixedTemp(rdx);
- LInstruction* result =
- DefineFixed(new(zone()) LModI(dividend, divisor, temp), rdx);
- bool can_deopt = (instr->right()->CanBeZero() ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->RangeCanInclude(kMinInt) &&
- instr->right()->RangeCanInclude(-1)) ||
- (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative() &&
- instr->CanBeZero()));
- return can_deopt ? AssignEnvironment(result) : result;
+ LInstruction* result = DefineFixed(new(zone()) LModI(
+ dividend, divisor, temp), rdx);
+ if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h Mon Mar 10 10:39:17 2014
UTC
+++ /branches/bleeding_edge/src/x64/lithium-x64.h Tue Mar 11 11:57:27 2014
UTC
@@ -736,8 +736,6 @@
LOperand* left() { return inputs_[0]; }
LOperand* right() { return inputs_[1]; }
LOperand* temp() { return temps_[0]; }
-
- bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
--
--
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.