inline single-use function across loop (#2594)

This commit is contained in:
Alex Lam S.L
2017-12-14 19:24:54 +08:00
committed by GitHub
parent 3f18a61532
commit 90313875f7
2 changed files with 80 additions and 2 deletions

View File

@@ -672,3 +672,78 @@ empty_body: {
}
}
}
inline_loop_1: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function f() {
return x();
}
for (;;) f();
}
expect: {
for (;;) x();
}
}
inline_loop_2: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
for (;;) f();
function f() {
return x();
}
}
expect: {
for (;;) x();
}
}
inline_loop_3: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var f = function() {
return x();
};
for (;;) f();
}
expect: {
for (;;) x();
}
}
inline_loop_4: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
for (;;) f();
var f = function() {
return x();
};
}
expect: {
for (;;) f();
var f = function() {
return x();
};
}
}