From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32144 invoked by alias); 20 May 2009 21:38:53 -0000 Received: (qmail 31937 invoked by uid 48); 20 May 2009 21:38:29 -0000 Date: Wed, 20 May 2009 21:38:00 -0000 Message-ID: <20090520213829.31936.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/39942] Nonoptimal code - leaveq; xchg %ax,%ax; retq In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "vvv at ru dot ru" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg01736.txt.bz2 ------- Comment #49 from vvv at ru dot ru 2009-05-20 21:38 ------- (In reply to comment #48) How this patches work? Is it required some special options? # /media/disk-1/B/bin/gcc --version gcc (GCC) 4.5.0 20090520 (experimental) # cat test.c void f(int i) { if (i == 1) F(1); if (i == 2) F(2); if (i == 3) F(3); if (i == 4) F(4); if (i == 5) F(5); } extern int F(int m); void func(int x) { int u = F(x); while (u) u = F(u)*3+1; } # /media/disk-1/B/bin/gcc -o t test.c -O2 -c -mtune=k8 # objdump -d t 0000000000000000 : 0: 83 ff 01 cmp $0x1,%edi 3: 74 1b je 20 5: 83 ff 02 cmp $0x2,%edi 8: 74 16 je 20 a: 83 ff 03 cmp $0x3,%edi d: 74 11 je 20 f: 83 ff 04 cmp $0x4,%edi 12: 74 0c je 20 14: 83 ff 05 cmp $0x5,%edi 17: 74 07 je 20 19: f3 c3 repz retq 1b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 20: 31 c0 xor %eax,%eax 22: e9 00 00 00 00 jmpq 27 27: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) 2e: 00 00 0000000000000030 : 30: 48 83 ec 08 sub $0x8,%rsp 34: e8 00 00 00 00 callq 39 39: 85 c0 test %eax,%eax 3b: 89 c7 mov %eax,%edi 3d: 74 0e je 4d 3f: 90 nop 40: e8 00 00 00 00 callq 45 45: 8d 7c 40 01 lea 0x1(%rax,%rax,2),%edi 49: 85 ff test %edi,%edi 4b: 75 f3 jne 40 4d: 48 83 c4 08 add $0x8,%rsp 51: c3 retq I can't see any padding in function f :( PS. In file config/i386/i386.c (ix86_avoid_jump_mispredicts) /* Look for all minimal intervals of instructions containing 4 jumps. ... Not jumps, but _branches_ (CALL, JMP, conditional branches, or returns) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39942