[Bug target/39942] Nonoptimal code - leaveq; xchg %ax,%ax; retq

vvv at ru dot ru gcc-bugzilla@gcc.gnu.org
Wed Apr 29 19:17:00 GMT 2009



------- Comment #15 from vvv at ru dot ru  2009-04-29 19:16 -------
One more example 5-bytes nop between leaveq and retq.

# cat test.c

void wait_for_enter()
{
        int u = getchar();
        while (!u)
                u = getchar()-13;
}
main()
{
wait_for_enter();
}

# gcc -o t.out test.c -O2 -march=core2 -fno-omit-frame-pointer
# objdump -d t.out
...
0000000000400540 <wait_for_enter>:
  400540:       55                      push   %rbp
  400541:       31 c0                   xor    %eax,%eax
  400543:       48 89 e5                mov    %rsp,%rbp
  400546:       e8 f5 fe ff ff          callq  400440 <getchar@plt>
  40054b:       85 c0                   test   %eax,%eax
  40054d:       75 13                   jne    400562 <wait_for_enter+0x22>
  40054f:       90                      nop    
  400550:       31 c0                   xor    %eax,%eax
  400552:       e8 e9 fe ff ff          callq  400440 <getchar@plt>
  400557:       83 f8 0d                cmp    $0xd,%eax
  40055a:       66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
  400560:       74 ee                   je     400550 <wait_for_enter+0x10>
  400562:       c9                      leaveq 
  400563:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)  <--NONOPTIMAL!
  400568:       c3                      retq   
  400569:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)

0000000000400570 <main>:
  400570:       55                      push   %rbp
  400571:       31 c0                   xor    %eax,%eax
  400573:       48 89 e5                mov    %rsp,%rbp
  400576:       e8 c5 ff ff ff          callq  400540 <wait_for_enter>
  40057b:       c9                      leaveq 
  40057c:       c3                      retq   
  40057d:       90                      nop    
  40057e:       90                      nop    
  40057f:       90                      nop    

So bug unresolved.


-- 

vvv at ru dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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



More information about the Gcc-bugs mailing list