Currently the compiler does not do the kind of optimization you
describe. A function is compiled once, and computes all of its
results. The caller receives all the results, and ignores ones that
it does not need.
Of course, if the function is inlined, then any code leading to
results that are not needed will be discarded. But most functions are
not inlined.
We could implement the general optimization by compiling a function
multiple times, for each permutation of the possible results. But I
think it's clear that that effort would generally be wasted. So we
would need some way to decide when this optimization would be useful.
And note that any effort in this area would tend to go against the
overall goal of fast compilation time.
Ian