Reviewers: Sven Panne,
Message:
PTAL
Description:
Cleanup some of the range uses in ModI/DivI.
BUG=v8:3204
LOG=y
Please review this at https://codereview.chromium.org/191293013/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+19, -32 lines):
M src/a64/lithium-a64.cc
M src/a64/lithium-codegen-a64.cc
M src/arm/lithium-arm.cc
M src/arm/lithium-codegen-arm.cc
M src/hydrogen-instructions.h
M src/ia32/lithium-codegen-ia32.cc
M src/ia32/lithium-ia32.cc
M src/x64/lithium-codegen-x64.cc
M src/x64/lithium-x64.cc
Index: src/a64/lithium-a64.cc
diff --git a/src/a64/lithium-a64.cc b/src/a64/lithium-a64.cc
index
dff700324ff74c9661a97aa71dbfbdd101a9de0a..728ec0ce1c894929cb83b523df6e2ec0eebb2cd1
100644
--- a/src/a64/lithium-a64.cc
+++ b/src/a64/lithium-a64.cc
@@ -1846,9 +1846,9 @@ LInstruction* LChunkBuilder::DoModI(HMod* instr) {
LOperand* divisor = UseRegister(instr->right());
LInstruction* result =
DefineAsRegister(new(zone()) LModI(dividend, divisor));
- bool can_deopt = (instr->right()->CanBeZero() ||
+ bool can_deopt = (instr->CheckFlag(HValue::kCanBeDivByZero) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative() &&
instr->CanBeZero()));
+ instr->left()->CanBeNegative()));
return can_deopt ? AssignEnvironment(result) : result;
}
Index: src/a64/lithium-codegen-a64.cc
diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc
index
6236eb92f8fd9931a9efed3d88201736558a3dda..e3a48df294c9ebfd4a2320e2b856371102ea69d2
100644
--- a/src/a64/lithium-codegen-a64.cc
+++ b/src/a64/lithium-codegen-a64.cc
@@ -4197,7 +4197,7 @@ void LCodeGen::DoModI(LModI* instr) {
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);
@@ -4207,8 +4207,7 @@ void LCodeGen::DoModI(LModI* instr) {
}
__ Msub(result, result, divisor, dividend);
if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->hydrogen()->left()->CanBeNegative() &&
- instr->hydrogen()->CanBeZero()) {
+ instr->hydrogen()->left()->CanBeNegative()) {
__ Cbnz(result, &done);
if (deopt.is_bound()) { // TODO(all) This is a hack, remove this...
__ Tbnz(dividend, kWSignBit, &deopt);
Index: src/arm/lithium-arm.cc
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index
f12b6eaeb0206ac18e66668722f9b78103fafbcd..6c6e50b0e3d7dfa8f4fdc99ce122b5be44d14222
100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -1383,13 +1383,12 @@ LInstruction* LChunkBuilder::DoModI(HMod* instr) {
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)));
+ bool can_deopt = (instr->CheckFlag(HValue::kCanBeDivByZero) ||
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
+ instr->left()->RangeCanInclude(kMinInt) &&
+ instr->right()->RangeCanInclude(-1)) ||
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
+ instr->left()->CanBeNegative()));
return can_deopt ? AssignEnvironment(result) : result;
} else {
LOperand* dividend = UseRegister(instr->left());
@@ -1398,9 +1397,8 @@ LInstruction* LChunkBuilder::DoModI(HMod* instr) {
LOperand* temp2 = FixedTemp(d11);
LInstruction* result =
DefineAsRegister(new(zone()) LModI(dividend, divisor, temp,
temp2));
- bool can_deopt = (instr->right()->CanBeZero() ||
+ bool can_deopt = (instr->CheckFlag(HValue::kCanBeDivByZero) ||
(instr->left()->CanBeNegative() &&
- instr->CanBeZero() &&
instr->CheckFlag(HValue::kBailoutOnMinusZero)));
return can_deopt ? AssignEnvironment(result) : result;
}
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index
53d15379a6cb852ae901af53bd03022afc04a008..7c0bab53da8d17eb49ec1b6065ee74bb1629fdf1
100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -1188,7 +1188,7 @@ void LCodeGen::DoModI(LModI* instr) {
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());
}
@@ -1219,7 +1219,6 @@ void LCodeGen::DoModI(LModI* instr) {
// 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)) {
__ cmp(result_reg, Operand::Zero());
__ b(ne, &done);
@@ -1247,7 +1246,7 @@ void LCodeGen::DoModI(LModI* instr) {
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());
}
@@ -1277,7 +1276,6 @@ void LCodeGen::DoModI(LModI* instr) {
// 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)) {
__ b(ne, &done);
__ cmp(left_reg, Operand::Zero());
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
36ef717c5dfd0d019450d4748d4e2654fa267b63..e333311a2410c18c14545b648225d9d82bd94fdd
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -855,7 +855,6 @@ class HValue : public ZoneObject {
// 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);
}
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc
b/src/ia32/lithium-codegen-ia32.cc
index
56d850b5890c7aaa35a1aba52ed00bf10fe24bfb..d28759f7d9ad95fa344a6bd388810b6682b5776e
100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -1448,7 +1448,7 @@ void LCodeGen::DoModI(LModI* instr) {
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());
}
@@ -1475,7 +1475,6 @@ void LCodeGen::DoModI(LModI* instr) {
// 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)) {
Label positive_left;
__ test(left_reg, Operand(left_reg));
Index: src/ia32/lithium-ia32.cc
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index
c4ad7e8020d8f2aea6e15110f87245320189e055..19649670fecbe654f5d98710c9d4c804664260e7
100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1478,13 +1478,12 @@ LInstruction* LChunkBuilder::DoModI(HMod* instr) {
LOperand* temp = FixedTemp(edx);
LInstruction* result =
DefineFixed(new(zone()) LModI(dividend, divisor, temp), edx);
- bool can_deopt = (instr->right()->CanBeZero() ||
+ bool can_deopt = (instr->CheckFlag(HValue::kCanBeDivByZero) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
instr->left()->RangeCanInclude(kMinInt) &&
instr->right()->RangeCanInclude(-1)) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative() &&
- instr->CanBeZero()));
+ instr->left()->CanBeNegative()));
return can_deopt ? AssignEnvironment(result) : result;
}
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index
1b6a97b22d2ddfa377ba85c1c45ffcfb2d373365..1396e889362e7506a2dfe4b659c2ebf33ff49184
100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -1048,9 +1048,6 @@ void LCodeGen::DoModByConstI(LModByConstI* instr) {
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();
@@ -1066,7 +1063,7 @@ void LCodeGen::DoModI(LModI* instr) {
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());
}
@@ -1094,7 +1091,6 @@ void LCodeGen::DoModI(LModI* instr) {
// 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)) {
Label positive_left;
__ testl(left_reg, left_reg);
Index: src/x64/lithium-x64.cc
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
index
74390e6fcadb696d22893f6f670be4544460e030..a4783b69eaaa2db906283d790f0956448b9d64cf
100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -1399,13 +1399,12 @@ LInstruction* LChunkBuilder::DoModI(HMod* instr) {
LOperand* temp = FixedTemp(rdx);
LInstruction* result =
DefineFixed(new(zone()) LModI(dividend, divisor, temp), rdx);
- bool can_deopt = (instr->right()->CanBeZero() ||
+ bool can_deopt = (instr->CheckFlag(HValue::kCanBeDivByZero) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
instr->left()->RangeCanInclude(kMinInt) &&
instr->right()->RangeCanInclude(-1)) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
- instr->left()->CanBeNegative() &&
- instr->CanBeZero()));
+ instr->left()->CanBeNegative()));
return can_deopt ? AssignEnvironment(result) : result;
}
--
--
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.