-
Notifications
You must be signed in to change notification settings - Fork 0
/
opt.txt
executable file
·60 lines (51 loc) · 1.13 KB
/
opt.txt
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class Main {
void main() {
Int a;
Int b;
Int c;
Int d;
Int e;
Int f;
Gen g;
g = new Gen();
// dead code
a = 4;
b = a + c;
d = 100 + a;
// copy prop + constant folding
a = 3; // -> ""
b = a; // -> ""
println(b); // -> println(3)
println("\n");
g.val = a;
println(g.val + 4); // -> println(7);
println("\n");
g.gen();
println(g.val); // no change
println("\n");
// copy prop + common sub expr
a = g.gen();
b = a; // -> ""
c = b; // -> ""
d = b + a; // -> a + a
e = c + b + d; // -> d + d
println(d + e);
println("\n"); // print 6
c = g.val + a;
println(g.val + a); // -> println(c);
println("\n");
// dead code
a = 4;
b = 5 + 10; // 15
c = b + a - 10; // 9
if (c > a) {
println("c > a\n"); // print this
} else {
println("c <= a\n");
}
}
}
class Gen {
Int val;
Int gen() { return 1; }
}