Debian Codegraph @

js/src/jit-test/tests/ion/merge-phi-usage-analysis.js

raw
1
2 function expensive() {
3 with({}) {}
4 }
5
6 function phi_merge_0(i) {
7 // These computations can overflow, if the output is not truncated.
8 i = i | 0;
9 var a0 = i + i;
10 var a1 = i + i;
11
12 if ((a1 | 0) - ((2 * i) | 0)) {
13 // Good candidate for branch pruning, which marks only a1 as having
14 // removed uses.
15 expensive();
16 expensive();
17 expensive();
18 expensive();
19 expensive();
20 }
21
22 // Simple branch made to let GVN merge the Phi instructions.
23 if (a1 % 3 == 1) {
24 a1 = 2 * i;
25 a0 = 2 * i;
26 }
27
28 // a0 is never used, but a1 is truncated.
29 return a1 | 0;
30 }
31
32 function phi_merge_1(i) {
33 // These computations can overflow, if the output is not truncated.
34 i = i | 0;
35 var a1 = i + i;
36 var a0 = i + i;
37
38 if ((a1 | 0) - ((2 * i) | 0)) {
39 // Good candidate for branch pruning, which marks only a1 as having
40 // removed uses.
41 expensive();
42 expensive();
43 expensive();
44 expensive();
45 expensive();
46 }
47
48 // Simple branch made to let GVN merge the Phi instructions.
49 if (a1 % 3 == 1) {
50 a1 = 2 * i;
51 a0 = 2 * i;
52 }
53
54 // a0 is never used, but a1 is truncated.
55 return a1 | 0;
56 }
57
58 for (var j = 0; j < 300; j++) {
59 for (var i = 1; i == (i | 0); i = 2 * i + 1) {
60 assertEq(phi_merge_0(i) < 0x80000000, true);
61 assertEq(phi_merge_1(i) < 0x80000000, true);
62 }
63 }