public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57430] Redundant move instruction is produced after function inlining
       [not found] <bug-57430-4@http.gcc.gnu.org/bugzilla/>
@ 2013-05-27 11:48 ` ysrumyan at gmail dot com
  2013-05-29 12:37 ` [Bug rtl-optimization/57430] " ysrumyan at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: ysrumyan at gmail dot com @ 2013-05-27 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Yuri Rumyantsev <ysrumyan at gmail dot com> ---
Created attachment 30203
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30203&action=edit
testcase

Need to compile with "-O2 -m32" options on x86.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/57430] Redundant move instruction is produced after function inlining
       [not found] <bug-57430-4@http.gcc.gnu.org/bugzilla/>
  2013-05-27 11:48 ` [Bug tree-optimization/57430] Redundant move instruction is produced after function inlining ysrumyan at gmail dot com
@ 2013-05-29 12:37 ` ysrumyan at gmail dot com
  2013-05-29 12:39 ` ysrumyan at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: ysrumyan at gmail dot com @ 2013-05-29 12:37 UTC (permalink / raw)
  To: gcc-bugs

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)>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/57430] Redundant move instruction is produced after function inlining
       [not found] <bug-57430-4@http.gcc.gnu.org/bugzilla/>
  2013-05-27 11:48 ` [Bug tree-optimization/57430] Redundant move instruction is produced after function inlining ysrumyan at gmail dot com
  2013-05-29 12:37 ` [Bug rtl-optimization/57430] " ysrumyan at gmail dot com
@ 2013-05-29 12:39 ` ysrumyan at gmail dot com
  2013-06-11 11:02 ` ysrumyan at gmail dot com
  2021-07-25  0:33 ` [Bug tree-optimization/57430] " pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: ysrumyan at gmail dot com @ 2013-05-29 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Yuri Rumyantsev <ysrumyan at gmail dot com> ---
Created attachment 30213
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30213&action=edit
modified testcase

This is modified testcase which does not have a problem with redundant move
instruction in innermost loop.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/57430] Redundant move instruction is produced after function inlining
       [not found] <bug-57430-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2013-05-29 12:39 ` ysrumyan at gmail dot com
@ 2013-06-11 11:02 ` ysrumyan at gmail dot com
  2021-07-25  0:33 ` [Bug tree-optimization/57430] " pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: ysrumyan at gmail dot com @ 2013-06-11 11:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Yuri Rumyantsev <ysrumyan at gmail dot com> ---
I have not seen any comments about my latest note - have you any ideas about
this issue?

Thanks ahead.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/57430] Redundant move instruction is produced after function inlining
       [not found] <bug-57430-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-06-11 11:02 ` ysrumyan at gmail dot com
@ 2021-07-25  0:33 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-25  0:33 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |tree-optimization

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So on the trunk, it looks like the inlined version has only one mov while the
out of line one has two.

inlined:
.L19:
        cmpq    %rax, %rsi
        je      .L18
.L17:
        movq    %rax, %rdx
        movq    24(%rax), %rax
        testq   %rax, %rax
        jne     .L19

out of line:
.L7:
        movq    %rdx, %rax
.L4:
        cmpq    %rax, %rsi
        je      .L3
        movq    24(%rax), %rdx
        movq    %rax, %rcx
        testq   %rdx, %rdx
        jne     .L7

Note this is 64bit x86.

inlined:
  <bb 10> [local count: 376074471]:
  if (first_24 != curr_34)
    goto <bb 11>; [94.50%]
  else
    goto <bb 12>; [5.50%]

  <bb 11> [local count: 397962402]:
  # curr_55 = PHI <curr_34(10), head.0_9(9)>
  curr_34 = curr_55->next;
  if (curr_34 != 0B)
    goto <bb 10>; [94.50%]
  else
    goto <bb 13>; [5.50%]

out of line:
  <bb 3> [local count: 1014686024]:
  # curr_24 = PHI <curr_15(4), _1(2)>
  # prev_25 = PHI <curr_24(4), 0B(2)>
  if (elt_12(D) != curr_24)
    goto <bb 4>; [94.50%]
  else
    goto <bb 5>; [5.50%]

  <bb 4> [local count: 958878294]:
  curr_15 = curr_24->next;
  if (curr_15 != 0B)
    goto <bb 3>; [93.84%]
  else
    goto <bb 8>; [6.16%]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-25  0:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-57430-4@http.gcc.gnu.org/bugzilla/>
2013-05-27 11:48 ` [Bug tree-optimization/57430] Redundant move instruction is produced after function inlining ysrumyan at gmail dot com
2013-05-29 12:37 ` [Bug rtl-optimization/57430] " ysrumyan at gmail dot com
2013-05-29 12:39 ` ysrumyan at gmail dot com
2013-06-11 11:02 ` ysrumyan at gmail dot com
2021-07-25  0:33 ` [Bug tree-optimization/57430] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).