From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13640 invoked by alias); 28 Apr 2009 17:10:50 -0000 Received: (qmail 13565 invoked by uid 48); 28 Apr 2009 17:10:28 -0000 Date: Tue, 28 Apr 2009 17:10:00 -0000 Message-ID: <20090428171028.13564.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-04/txt/msg02745.txt.bz2 ------- Comment #3 from vvv at ru dot ru 2009-04-28 17:10 ------- Additional examples from Linux Kernel 2.6.29.1: (Note: conditional statement at the end of all fuctions!) ================= linux/drivers/video/console/bitblit.c void fbcon_set_bitops(struct fbcon_ops *ops) { ops->bmove = bit_bmove; ops->clear = bit_clear; ops->putcs = bit_putcs; ops->clear_margins = bit_clear_margins; ops->cursor = bit_cursor; ops->update_start = bit_update_start; ops->rotate_font = NULL; if (ops->rotate) fbcon_set_rotate(ops); } ================ ffffffff8020a5e0 : ffffffff8020a5e0: 55 push %rbp ffffffff8020a5e1: bf 01 00 00 00 mov $0x1,%edi ffffffff8020a5e6: 48 89 e5 mov %rsp,%rbp ffffffff8020a5e9: e8 c2 fd 35 00 callq ffffffff8056a3b0 ffffffff8020a5ee: 65 48 8b 04 25 10 00 mov %gs:0x10,%rax ffffffff8020a5f5: 00 00 ffffffff8020a5f7: 48 2d c8 1f 00 00 sub $0x1fc8,%rax ffffffff8020a5fd: f0 0f ba 28 10 lock btsl $0x10,(%rax) ffffffff8020a602: 19 d2 sbb %edx,%edx ffffffff8020a604: 85 d2 test %edx,%edx ffffffff8020a606: 75 0a jne ffffffff8020a612 ffffffff8020a608: 0f 20 e0 mov %cr4,%rax ffffffff8020a60b: 48 83 c8 04 or $0x4,%rax ffffffff8020a60f: 0f 22 e0 mov %rax,%cr4 ffffffff8020a612: bf 01 00 00 00 mov $0x1,%edi ffffffff8020a617: e8 e4 fc 35 00 callq ffffffff8056a300 ffffffff8020a61c: 65 48 8b 04 25 10 00 mov %gs:0x10,%rax ffffffff8020a623: 00 00 ffffffff8020a625: f6 80 38 e0 ff ff 08 testb $0x8,-0x1fc8(%rax) ffffffff8020a62c: 75 02 jne ffffffff8020a630 ffffffff8020a62e: c9 leaveq ffffffff8020a62f: c3 retq ffffffff8020a630: e8 2b 99 35 00 callq ffffffff80563f60 ffffffff8020a635: c9 leaveq ffffffff8020a636: 66 90 xchg %ax,%ax ffffffff8020a638: c3 retq ================== /arch/x86/kernel/io_delay.c void native_io_delay(void) { switch (io_delay_type) { default: case CONFIG_IO_DELAY_TYPE_0X80: asm volatile ("outb %al, $0x80"); break; case CONFIG_IO_DELAY_TYPE_0XED: asm volatile ("outb %al, $0xed"); break; case CONFIG_IO_DELAY_TYPE_UDELAY: /* * 2 usecs is an upper-bound for the outb delay but * note that udelay doesn't have the bus-level * side-effects that outb does, nor does udelay() have * precise timings during very early bootup (the delays * are shorter until calibrated): */ udelay(2); case CONFIG_IO_DELAY_TYPE_NONE: break; } } EXPORT_SYMBOL(native_io_delay); ffffffff802131e0 : ffffffff802131e0: 55 push %rbp ffffffff802131e1: 8b 05 3d b3 54 00 mov 0x54b33d(%rip),%eax # ffffffff8075e524 ffffffff802131e7: 48 89 e5 mov %rsp,%rbp ffffffff802131ea: 83 f8 02 cmp $0x2,%eax ffffffff802131ed: 74 29 je ffffffff80213218 ffffffff802131ef: 83 f8 03 cmp $0x3,%eax ffffffff802131f2: 74 06 je ffffffff802131fa ffffffff802131f4: ff c8 dec %eax ffffffff802131f6: 74 10 je ffffffff80213208 ffffffff802131f8: e6 80 out %al,$0x80 ffffffff802131fa: c9 leaveq ffffffff802131fb: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) ffffffff80213200: c3 retq ffffffff80213201: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ffffffff80213208: e6 ed out %al,$0xed ffffffff8021320a: c9 leaveq ffffffff8021320b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) ffffffff80213210: c3 retq ffffffff80213211: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ffffffff80213218: bf 8e 21 00 00 mov $0x218e,%edi ffffffff8021321d: 0f 1f 00 nopl (%rax) ffffffff80213220: e8 fb ac 1e 00 callq ffffffff803fdf20 <__const_udelay> ffffffff80213225: c9 leaveq ffffffff80213226: 66 90 xchg %ax,%ax ffffffff80213228: c3 retq =============== arch/x86/mm/ioremap.c int ioremap_change_attr(unsigned long vaddr, unsigned long size, unsigned long prot_val) { unsigned long nrpages = size >> PAGE_SHIFT; int err; switch (prot_val) { case _PAGE_CACHE_UC: default: err = _set_memory_uc(vaddr, nrpages); break; case _PAGE_CACHE_WC: err = _set_memory_wc(vaddr, nrpages); break; case _PAGE_CACHE_WB: err = _set_memory_wb(vaddr, nrpages); break; } return err; } ffffffff8022df60 : ffffffff8022df60: 55 push %rbp ffffffff8022df61: 48 c1 ee 0c shr $0xc,%rsi ffffffff8022df65: 48 89 e5 mov %rsp,%rbp ffffffff8022df68: 48 85 d2 test %rdx,%rdx ffffffff8022df6b: 75 0b jne ffffffff8022df78 ffffffff8022df6d: e8 2e 18 00 00 callq ffffffff8022f7a0 <_set_memory_wb> ffffffff8022df72: c9 leaveq ffffffff8022df73: c3 retq ffffffff8022df74: 0f 1f 40 00 nopl 0x0(%rax) ffffffff8022df78: 48 83 fa 08 cmp $0x8,%rdx ffffffff8022df7c: 0f 1f 40 00 nopl 0x0(%rax) ffffffff8022df80: 74 16 je ffffffff8022df98 ffffffff8022df82: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) ffffffff8022df88: e8 53 19 00 00 callq ffffffff8022f8e0 <_set_memory_uc> ffffffff8022df8d: c9 leaveq ffffffff8022df8e: 66 90 xchg %ax,%ax ffffffff8022df90: c3 retq ffffffff8022df91: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ffffffff8022df98: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) ffffffff8022df9f: 00 ffffffff8022dfa0: e8 0b 19 00 00 callq ffffffff8022f8b0 <_set_memory_wc> ffffffff8022dfa5: c9 leaveq ffffffff8022dfa6: 66 90 xchg %ax,%ax ffffffff8022dfa8: c3 retq ffffffff8022dfa9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ============== kernel/sched.c int sched_group_set_rt_period(struct task_group *tg, long rt_period_us) { u64 rt_runtime, rt_period; rt_period = (u64)rt_period_us * NSEC_PER_USEC; rt_runtime = tg->rt_bandwidth.rt_runtime; if (rt_period == 0) return -EINVAL; return tg_set_bandwidth(tg, rt_period, rt_runtime); } ffffffff8023f810 : ffffffff8023f810: 55 push %rbp ffffffff8023f811: 48 69 f6 e8 03 00 00 imul $0x3e8,%rsi,%rsi ffffffff8023f818: 48 89 e5 mov %rsp,%rbp ffffffff8023f81b: 48 8b 57 50 mov 0x50(%rdi),%rdx ffffffff8023f81f: b8 ea ff ff ff mov $0xffffffea,%eax ffffffff8023f824: 48 85 f6 test %rsi,%rsi ffffffff8023f827: 75 07 jne ffffffff8023f830 ffffffff8023f829: c9 leaveq ffffffff8023f82a: c3 retq ffffffff8023f82b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) ffffffff8023f830: e8 bb fe ff ff callq ffffffff8023f6f0 ffffffff8023f835: c9 leaveq ffffffff8023f836: 66 90 xchg %ax,%ax ffffffff8023f838: c3 retq ffffffff8023f839: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ============== kernel/sched_rt.c static void pre_schedule_rt(struct rq *rq, struct task_struct *prev) { /* Try to pull RT tasks here if we lower this rq's prio */ if (unlikely(rt_task(prev)) && rq->rt.highest_prio > prev->prio) pull_rt_task(rq); } static void switched_from_rt(struct rq *rq, struct task_struct *p, int running) { /* * If there are other RT tasks then we will reschedule * and the scheduling of the other RT tasks will handle * the balancing. But if we are the last RT task * we may need to handle the pulling of RT tasks * now. */ if (!rq->rt.rt_nr_running) pull_rt_task(rq); } ffffffff802452b0 : ffffffff802452b0: 55 push %rbp ffffffff802452b1: 48 89 e5 mov %rsp,%rbp ffffffff802452b4: 48 83 bf 70 07 00 00 cmpq $0x0,0x770(%rdi) ffffffff802452bb: 00 ffffffff802452bc: 74 02 je ffffffff802452c0 ffffffff802452be: c9 leaveq ffffffff802452bf: c3 retq ffffffff802452c0: e8 6b fd ff ff callq ffffffff80245030 ffffffff802452c5: c9 leaveq ffffffff802452c6: 66 90 xchg %ax,%ax ffffffff802452c8: c3 retq ffffffff802452c9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ffffffff802452d0 : ffffffff802452d0: 55 push %rbp ffffffff802452d1: 8b 46 20 mov 0x20(%rsi),%eax ffffffff802452d4: 48 89 e5 mov %rsp,%rbp ffffffff802452d7: 83 f8 63 cmp $0x63,%eax ffffffff802452da: 7f 08 jg ffffffff802452e4 ffffffff802452dc: 39 87 78 07 00 00 cmp %eax,0x778(%rdi) ffffffff802452e2: 7f 0c jg ffffffff802452f0 ffffffff802452e4: c9 leaveq ffffffff802452e5: c3 retq ffffffff802452e6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1) ffffffff802452ed: 00 00 00 ffffffff802452f0: e8 3b fd ff ff callq ffffffff80245030 ffffffff802452f5: c9 leaveq ffffffff802452f6: 66 90 xchg %ax,%ax ffffffff802452f8: c3 retq ffffffff802452f9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ============= linux/kernel/timer.c void msleep(unsigned int msecs) { unsigned long timeout = msecs_to_jiffies(msecs) + 1; while (timeout) timeout = schedule_timeout_uninterruptible(timeout); } EXPORT_SYMBOL(msleep); ffffffff80256120 : ffffffff80256120: 55 push %rbp ffffffff80256121: 48 89 e5 mov %rsp,%rbp ffffffff80256124: e8 a7 94 ff ff callq ffffffff8024f5d0 ffffffff80256129: 48 89 c7 mov %rax,%rdi ffffffff8025612c: 48 ff c7 inc %rdi ffffffff8025612f: 74 14 je ffffffff80256145 ffffffff80256131: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ffffffff80256138: e8 c3 ed 30 00 callq ffffffff80564f00 ffffffff8025613d: 48 89 c7 mov %rax,%rdi ffffffff80256140: 48 85 c0 test %rax,%rax ffffffff80256143: 75 f3 jne ffffffff80256138 ffffffff80256145: c9 leaveq ffffffff80256146: 66 90 xchg %ax,%ax ffffffff80256148: c3 retq ffffffff80256149: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ================ mm/shemem.c static int shmem_xattr_security_get(struct inode *inode, const char *name, void *buffer, size_t size) { if (strcmp(name, "") == 0) return -EINVAL; return xattr_getsecurity(inode, name, buffer, size); } static int shmem_xattr_security_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { if (strcmp(name, "") == 0) return -EINVAL; return security_inode_setsecurity(inode, name, value, size, flags); } ffffffff802b9ff0 : ffffffff802b9ff0: 55 push %rbp ffffffff802b9ff1: b8 ea ff ff ff mov $0xffffffea,%eax ffffffff802b9ff6: 48 89 e5 mov %rsp,%rbp ffffffff802b9ff9: 80 3e 00 cmpb $0x0,(%rsi) ffffffff802b9ffc: 75 02 jne ffffffff802ba000 ffffffff802b9ffe: c9 leaveq ffffffff802b9fff: c3 retq ffffffff802ba000: e8 ab b1 0f 00 callq ffffffff803b51b0 ffffffff802ba005: c9 leaveq ffffffff802ba006: 66 90 xchg %ax,%ax ffffffff802ba008: c3 retq ffffffff802ba009: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ffffffff802ba010 : ffffffff802ba010: 55 push %rbp ffffffff802ba011: b8 ea ff ff ff mov $0xffffffea,%eax ffffffff802ba016: 48 89 e5 mov %rsp,%rbp ffffffff802ba019: 80 3e 00 cmpb $0x0,(%rsi) ffffffff802ba01c: 75 02 jne ffffffff802ba020 ffffffff802ba01e: c9 leaveq ffffffff802ba01f: c3 retq ffffffff802ba020: e8 2b b5 04 00 callq ffffffff80305550 ffffffff802ba025: c9 leaveq ffffffff802ba026: 66 90 xchg %ax,%ax ffffffff802ba028: c3 retq ffffffff802ba029: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) ========== linux/fs/file_table.c void fput(struct file *file) { if (atomic_long_dec_and_test(&file->f_count)) __fput(file); } EXPORT_SYMBOL(fput); ffffffff802e8da0 : ffffffff802e8da0: 55 push %rbp ffffffff802e8da1: 48 8d 47 28 lea 0x28(%rdi),%rax ffffffff802e8da5: 48 89 e5 mov %rsp,%rbp ffffffff802e8da8: f0 48 ff 08 lock decq (%rax) ffffffff802e8dac: 0f 94 c2 sete %dl ffffffff802e8daf: 84 d2 test %dl,%dl ffffffff802e8db1: 75 05 jne ffffffff802e8db8 ffffffff802e8db3: c9 leaveq ffffffff802e8db4: c3 retq ffffffff802e8db5: 0f 1f 00 nopl (%rax) ffffffff802e8db8: e8 03 fe ff ff callq ffffffff802e8bc0 <__fput> ffffffff802e8dbd: c9 leaveq ffffffff802e8dbe: 66 90 xchg %ax,%ax ffffffff802e8dc0: c3 retq ffffffff802e8dc1: 66 66 66 66 66 66 2e nopw %cs:0x0(%rax,%rax,1) ffffffff802e8dc8: 0f 1f 84 00 00 00 00 ffffffff802e8dcf: 00 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39942