 Chromium Code Reviews
 Chromium Code Reviews Issue 873143002:
  [turbofan] Better narrow the derived type for the right shift operation.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 873143002:
  [turbofan] Better narrow the derived type for the right shift operation.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| Index: src/compiler/typer.cc | 
| diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc | 
| index 4b3a8830a0fff9cbed6694b9588742225d262814..b63452f6cb31e004da08a2d5e3f2ae80d5e0121b 100644 | 
| --- a/src/compiler/typer.cc | 
| +++ b/src/compiler/typer.cc | 
| @@ -916,11 +916,15 @@ Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) { | 
| // Right-shifting a non-negative value cannot make it negative, nor larger. | 
| min = std::max(min, 0.0); | 
| max = std::min(max, lhs->Max()); | 
| + if (rhs->Min() > 0 && rhs->Max() <= 31) | 
| 
Benedikt Meurer
2015/01/26 07:23:47
Nit: please add { and }.
 | 
| + max = static_cast<int>(max) >> static_cast<int>(rhs->Min()); | 
| } | 
| if (lhs->Max() < 0) { | 
| // Right-shifting a negative value cannot make it non-negative, nor smaller. | 
| min = std::max(min, lhs->Min()); | 
| max = std::min(max, -1.0); | 
| + if (rhs->Min() > 0 && rhs->Max() <= 31) | 
| 
Benedikt Meurer
2015/01/26 07:23:47
Nit: please add { and }.
 | 
| + min = static_cast<int>(min) >> static_cast<int>(rhs->Min()); | 
| } | 
| if (rhs->Min() > 0 && rhs->Max() <= 31) { | 
| // Right-shifting by a positive value yields a small integer value. |