https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88971

--- Comment #7 from Marat Stanichenko <maratrus at mail dot ru> ---
(In reply to rguent...@suse.de from comment #6)
> > Do you believe that compiler can do better in such situations? Or the 
> > current
> > behaviour is perfectly valid and no improvements are really needed?
> 
> The compiler can of course do better when estimating the benefit of
> inlining.  It's just not entirely clear if it is reasonably easy to
> do so ... [let aside the -finline-function issue]

Is it only about inlining?

Unfortunately, I cannot evaluate the technical difficulties but in patterns
like presented here i.e.

```
if (condition)
  Function(param);
```

irrespective of the fact whether `Function()` is asked to be inlined or not
there are at least two observations that the compiler may notice before taking
an optimization decision:

a) Whether `Function(param)` is empty or not. In both scenarios in the example
presented `PrintBad<false>("<", ">", t)` and `PrintGood<false>("<", t)` are
actually empty.

b) Whether `param` is used in a `Function`. I think I can see the examples when
function calls like `PrintBad<false>(">", t)` generates a code to construct
parameter ">" despite the fact that not only it is not used but also the
function body is empty.

Of course, ideally I expect the parameter not to be constructed if it is not
used and the whole branch to be eliminated of the `Function` is empty and
`condition` does not have side effects. But as I said, I do not have enough
technical expertise to evaluate the cost. I speak from a solely user's
perspective.

What do you think is the best way to solve this? Keep tracking examples until
some critical mass is collected?

Reply via email to