• fedor's avatar
    binary-operator-reducer: reduce mul+div(shift) · 461e5b49
    fedor authored
    Reduction Input:
    
        ChangeInt32ToFloat64=>          TruncateFloat64ToInt32
                             Float64Mul=>
        ChangeInt32ToFloat64=>          Float64Div=>TruncateFloat64ToInt32
    
    Output:
    
             =>  TruncateInt64ToInt32
    Int64Mul
             =>  Int64Shr => TruncateInt64ToInt32
    
    Test code:
    
        function mul(a, b) {
          var l = a & 0x3ffffff;
          var h = b & 0x3ffffff;
          var m = l * h;
    
          var rl = m & 0x3ffffff;
          var rh = (m / 0x4000000) | 0;
    
          return rl | rh;
        }
    
        mul(1, 2);
        var a0 = mul(0x3ffffff, 0x3ffffff);
        mul(0x0, 0x0);
        %OptimizeFunctionOnNextCall(mul);
        var a1 = mul(0x3ffffff, 0x3ffffff);
    
        print(a0 + ' == ' + a1);
    
    BUG=
    R=mstarzinger@chromium.org
    
    Review URL: https://codereview.chromium.org/1350223006
    
    Cr-Commit-Position: refs/heads/master@{#31899}
    461e5b49
v8.gyp 81.2 KB