From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20280 invoked by alias); 16 Jul 2006 18:47:57 -0000 Received: (qmail 20270 invoked by uid 48); 16 Jul 2006 18:47:48 -0000 Date: Sun, 16 Jul 2006 18:47:00 -0000 Message-ID: <20060716184748.20269.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/28395] Improved division-by-constant code In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "vda dot linux at googlemail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-07/txt/msg01199.txt.bz2 List-Id: ------- Comment #9 from vda dot linux at googlemail dot com 2006-07-16 18:47 ------- The test program below shows that in this case doing division with div insn takes more instructions than with mul+shift. Also mul+shift path has absolutely useless "movl %edx, %eax" insn, shaving that will make it even smaller. Need to build newer gcc and retest... # cat t.c enum { B = 10 }; enum { shift_bits = 35 }; enum { K = (1ULL<> shift_bits; asm("#3"); } # gcc -Os -fomit-frame-pointer -S t.c # cat t.s .file "t.c" .text .globl f .type f, @function f: pushl %ebx #APP #1 #NO_APP movl $10, %edx movl %edx, %ebx movl 8(%esp), %eax xorl %edx, %edx divl %ebx movl %eax, a #APP #2 #NO_APP movl $-858993459, %eax mull 8(%esp) movl %edx, %eax shrl $3, %eax movl %eax, b #APP #3 #NO_APP popl %ebx ret .size f, .-f .comm a,4,4 .comm b,4,4 .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.4.3" -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28395