summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/range-analysis.js
blob: 86f4419135c1d7b1eb04a5d9dd9aedfa83c57e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// |jit-test|

// Only fails with Ion.
function add_xors_1() {
    var res = 0;
    var step = 4;
    for (var i = 0x7fffffff | 0; i >= (1 << step); i -= (i >> step)) {
        var x = i ^ (i << 1);
        res += (((x + x) + res + res) | 0);
    }
    return res;
}

var r1 = add_xors_1();
for (var i = 0; i < 100; i++) {
    var r2 = add_xors_1();
    assertEq(r2, r1);
}

// Only fails with JM
function add_xors_2() {
    var res = 0;
    var step = 4;
    for (var i = 0x7fffffff | 0; i >= (1 << step); i -= (i >> step)) {
        var x = i ^ (i << 1);
        res += ((x + x) + res + res) | 0;
    }
    return res;
}

var r1 = add_xors_2();
for (var i = 0; i < 100; i++) {
    var r2 = add_xors_2();
    assertEq(r1, r2);
}