From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6372 invoked by alias); 27 Jun 2006 13:57:12 -0000 Received: (qmail 6364 invoked by uid 22791); 27 Jun 2006 13:57:11 -0000 X-Spam-Check-By: sourceware.org Received: from smtp111.sbc.mail.mud.yahoo.com (HELO smtp111.sbc.mail.mud.yahoo.com) (68.142.198.210) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 27 Jun 2006 13:57:09 +0000 Received: (qmail 52436 invoked from network); 27 Jun 2006 13:57:07 -0000 Received: from unknown (HELO ?69.104.56.203?) (timothyprince@sbcglobal.net@69.104.56.203 with plain) by smtp111.sbc.mail.mud.yahoo.com with SMTP; 27 Jun 2006 13:57:07 -0000 Message-ID: <44A13931.9060802@sbcglobal.net> Date: Tue, 27 Jun 2006 13:57:00 -0000 From: Tim Prince Reply-To: tprince@myrealbox.com User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Coline Lelong-Pantel CC: gcc-help Subject: Re: question about gcc assembly References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-06/txt/msg00234.txt.bz2 Coline Lelong-Pantel wrote: > Hi > > I've compiled a short program with two different gcc versions > (3.2.3 and 3.4.3) but it seems that the produced assembly code > isn't the same. > > In fact 3.4.3 produce a more important code. For example when > gcc 3.2.3 produces : > movl $0x405c28f6, -4(%ebp) > > gcc 3.4.3 may use: > movl $0x405c28f6, %eax > movl %eax, -4(%ebp) > > I wonder why it now uses %eax register ? And is there any way > to prevent this, in order to have similar assembly code with > both gcc versions ? Maybe some kind of option ? > > Thanks for your answers. > Both gcc versions you quote are fairly old; if efficiency interests you, you might try a current version. Were you able to show a significant difference in performance on a CPU which is important to you? I would guess the most important reason for avoiding use of eax here would be to keep that register available for other use. The optimization could be affected by compiler switches (-Os, -O2) or by selection of -march option, and many other possibilities. Newer CPUs have hardware merging of operations, as well as stalls on certain immediate data operations, so it is impossible to know the performance implications from what you have presented.