http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57430

--- Comment #2 from Yuri Rumyantsev <ysrumyan at gmail dot com> ---
I don't believe that this is related to rtl optimizations, but rather to
inlining phase. To prove it I did small changes in t.c for remove.c (it now has
type void):

void remove (node ** head, node* elt)
{
  node* curr;
  node* prev;

  if (*head == 0)
    {
      return;
    }
  prev = 0;
  curr = *head;
  while (curr)
    {
      if (curr != elt)
    {
      prev = curr;
      curr = curr->next;
    }
      else
    {
      if (prev == 0)
        {
          *head = (*head)->next;
          break;
        }
      else
        {
          prev->next = curr->next;
          break;
        }
        }
    }

}

For modified test we still have the same issue with redundant move instruction.

Now we can do another test modification that performs manual partial inlining
for 'remove' (full source will be attached):
 Move test on zero head out of function to its call, i.e.  call of 'remove' is
guarded by test on non-null head in 'find' and remove this test out of
function, i.e. we have

       if (head)
         remove (&head, first)

For this modofied test we have optimal 6 instructions for innermost loop.

I assume that a problem related to phi-function construction after inlining,
namely for original test we have recurrent chain of phi's:

  <bb 14>:
  # prev_47 = PHI <prev_37(16), prev_51(13)>
  # prev_54 = PHI <prev_47(16), prev_25(13)>
(before expand phase)

but for modified test we have an ordinary phi:

  <bb 16>:
  # prev_52 = PHI <prev_38(15), prev_26(13)>

Reply via email to