-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.cs
169 lines (145 loc) · 2.42 KB
/
basic.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using SimpleJit.Testing;
public static class Foo {
public static int test_0_return_const ()
{
return 0;
}
public static int test_7_add_vals ()
{
int a = 4;
int b = 3;
int c = a + b;
return c;
}
public static int test_9_add_const ()
{
int a = 4;
int c = a + 5;
return c;
}
public static int test_4_1_3_add_arguments (int a, int b)
{
return a + b;
}
public static int test_2_cond ()
{
int a = 10;
int b = 20;
if (a > b)
return 1;
return 2;
}
public static int test_1_cond2 ()
{
int a = 11;
int b = 10;
if (a > b)
return 1;
return 2;
}
public static int test_2_comp_with_const ()
{
int a = 10;
if (a > 20)
return 1;
return 2;
}
public static int test_1_comp_with_const2 ()
{
int a = 10;
if (20 > a)
return 1;
return 2;
}
public static int test_1_10_20_comp_with_const2 (int a, int b)
{
int c = a;
if (b > c)
return 1;
return 2;
}
public static int test_3_1_44_cond_with_add (int a, int b)
{
int c = 0;
if (a > 0)
c = a;
else
c = b;
return c + 2;
}
public static int test_4_0_2_cond_with_add (int a, int b)
{
int c = 0;
if (a > 0)
c = a;
else
c = b;
return c + 2;
}
public static int test_45_simple_counting_loop () {
int res = 0;
for (int i = 0; i < 10; ++i) {
res += i;
}
return res;
}
public static int test_35_12_loop_with_limit (int limit) {
int acc = 0;
for (int i = 0; i < limit; ++i) {
if (i > 10)
acc += 2;
else
acc += 3;
}
return acc;
}
public static int test_30_call_other () {
return EarlyReturn (5);
}
public static int EarlyReturn (int v) {
if (v > 10)
return 20;
return 30;
}
public static int test_33_1_2_cprop_dce (int a, int b) {
int d = 10;
int e = 20;
int c = 0;
d = d + 1;
e = d + e;
if (a > b)
c = a + d;
else
a = b + e;
return c + a;
}
public static int test_30_3_10_imul (int a, int b) {
return a * b;
}
public static int test_130_3_10_imul (int a, int b) {
int c = a + b; //3 + 10 -> 13
int d = c * b; //13 * 10 -> 130
return d;
}
public static int test_30_3_imul (int a) {
return a * 10;
}
public static int test_1_load_bool () {
bool a = true;
return a? 1: 0;
}
public static int test_30_10_ind_load (int x)
{
int y = 20;
ref int z = ref y;
return x + z;
}
public static int test_41_10_add_const (int x)
{
int y = 30;
ref int z = ref y;
if (x > 9)
z = y + 1;
return x + z;
}
}