 Chromium Code Reviews
 Chromium Code Reviews Issue 191293013:
  Cleanup some of the range uses in ModI/DivI.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 191293013:
  Cleanup some of the range uses in ModI/DivI.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/a64/lithium-codegen-a64.cc | 
| diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc | 
| index ea826d6ffa53c6158675fcc3f6860dae6e75bceb..f82b3b344a0db0f608bedd6a433a4cd4a9871830 100644 | 
| --- a/src/a64/lithium-codegen-a64.cc | 
| +++ b/src/a64/lithium-codegen-a64.cc | 
| @@ -2607,20 +2607,18 @@ void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { | 
| // 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()); | 
| } | 
| // Deoptimize if remainder will not be 0. | 
| if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && | 
| - divisor != 1 && divisor != -1) { | 
| + Abs(divisor) != 1) { | 
| 
Sven Panne
2014/03/11 11:32:42
Hmmm, I consciously did not use Abs here (and simi
 
Benedikt Meurer
2014/03/11 11:56:35
Ok, makes sense.
 | 
| int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); | 
| __ Tst(dividend, mask); | 
| DeoptimizeIf(ne, instr->environment()); | 
| @@ -2657,8 +2655,7 @@ void LCodeGen::DoDivByConstI(LDivByConstI* instr) { | 
| // 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::DoDivByConstI(LDivByConstI* instr) { | 
| 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 @@ void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { | 
| // 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 @@ void LCodeGen::DoModByConstI(LModByConstI* instr) { | 
| // 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 @@ 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); | 
| @@ -4211,9 +4206,7 @@ void LCodeGen::DoModI(LModI* instr) { | 
| __ 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); |