From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16122 invoked by alias); 26 Feb 2007 14:35:42 -0000 Received: (qmail 16112 invoked by uid 22791); 26 Feb 2007 14:35:41 -0000 X-Spam-Check-By: sourceware.org Received: from mailfe01.swip.net (HELO swip.net) (212.247.154.1) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 26 Feb 2007 14:35:32 +0000 X-Cloudmark-Score: 0.000000 [] Received: from [193.217.102.48] (account mc467741@c2i.net HELO [10.0.0.249]) by mailfe01.swip.net (CommuniGate Pro SMTP 5.0.12) with ESMTPA id 403730748; Mon, 26 Feb 2007 15:35:29 +0100 From: Hans Petter Selasky To: Graham Stott Subject: Re: GCC has problems with 64-bit multiplication User-Agent: KMail/1.9.5 Cc: gcc-bugs@gcc.gnu.org References: <20070208150235.80441.qmail@web86107.mail.ird.yahoo.com> In-Reply-To: <20070208150235.80441.qmail@web86107.mail.ird.yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Date: Mon, 26 Feb 2007 14:35:00 -0000 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200702261535.06966.hselasky@c2i.net> 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: 2007-02/txt/msg02879.txt.bz2 On Thursday 08 February 2007 16:02, Graham Stott wrote: > All, > > Not a bug in GCC the result is correct as you've only asked for a 32-bit > multiply. Hi again, The problem was not that "mull" is used, but that "gcc 3.4.6" generates highly un-optimized code when I for example multiply a 16-bit integer by a 64-bit integer. It actually generates code where three multiplications are used instead of two. That has a speed impact. Code: #include #include int main() { int64_t temp; int16_t x; temp *= x; printf("%lld\n", temp); return 0; } objdump -D ./a.out 8048507: 89 4d e8 mov %ecx,0xffffffe8(%ebp) 804850a: 31 c0 xor %eax,%eax 804850c: 89 55 ec mov %edx,0xffffffec(%ebp) 804850f: f7 65 e8 mull 0xffffffe8(%ebp) 8048512: 6b 7d ec 00 imul $0x0,0xffffffec(%ebp),%edi 8048516: 89 d6 mov %edx,%esi 8048518: 89 c1 mov %eax,%ecx 804851a: 01 fe add %edi,%esi 804851c: 6b 45 e8 00 imul $0x0,0xffffffe8(%ebp),%eax 8048520: 83 e4 f0 and $0xfffffff0,%esp 8048523: 83 ec 14 sub $0x14,%esp 8048526: 8d 1c 06 lea (%esi,%eax,1),%ebx --HPS