| Index: src/x64/lithium-x64.cc
|
| diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
|
| index 74390e6fcadb696d22893f6f670be4544460e030..c567b73d1c78cdf029b6d847afe28a2dc3806976 100644
|
| --- a/src/x64/lithium-x64.cc
|
| +++ b/src/x64/lithium-x64.cc
|
| @@ -1248,16 +1248,15 @@ LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
|
| 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 @@ LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
|
| 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 @@ LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) {
|
| 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 @@ LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
|
| 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 @@ LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
|
| 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 @@ LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
|
| 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 @@ LInstruction* LChunkBuilder::DoModI(HMod* instr) {
|
| 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;
|
| }
|
|
|
|
|
|
|