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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'd say for musttail calls recursive inlining should never be desirable,
instead we should have turned that into a tail recursion.
Now, except for early inlining I think it should have happened already, IPA
inlining is done on functions which made it through all pre-IPA optimizations
which includes the tailr pass, so I think we should simply improve the tailr
pass to handle it.
With -fno-early-inlining -O2 it still fails:
Cannot handle D.2905.n_recurses = 0;
struct MyStruct foo (struct MyStruct m)
{
  unsigned int m$n_recurses;
  struct MyStruct D.2897;
  struct MyStruct D.2905;
  unsigned int _3;

  <bb 2> :
  m$n_recurses_9 = m.n_recurses;
  if (m$n_recurses_9 == 0)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  D.2905.n_recurses = 0;
  goto <bb 5>; [INV]

  <bb 4> :
  _3 = m$n_recurses_9 + 4294967295;
  D.2897.n_recurses = _3;
  D.2905 = foo (D.2897); [must tail call]

  <bb 5> :
  return D.2905;

}

but I don't understand why it just couldn't do m = D.2897; goto <bb 2>; in that
case.

Early inlining is more complicated, either we need to arrange for tailr to be
run on the to be inlined body before it is attempted to be early inlined, or we
need to optimize that (perhaps just for musttail calls) during early inlining
because we shouldn't inline one invocation of foo and keep there foo call.

Reply via email to