Different types of optimization help us to improve our code’s stability.
Tail splitting eliminates jumps by bringing common return statements into the blocks, so that
if(x) {
b = 1;
} else {
b = 2;
}
return b;
becomes
if(x) {
b = 1;
return b;
} else {
b = 2;
return b;
}
which is a speed optimization.
Tail merging, on the other hand, pulls duplicate instructions out of the blocks, which is a size optimization. Tail merging turns the following:
if(x) {
bar()
b = 1;
} else {
foo()
b = 1;
}
into this:
if(x) {
bar()
} else {
foo()
}
b = 1;
