From owner-freebsd-questions@FreeBSD.ORG Sun Apr 25 18:03:28 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6CD80106564A for ; Sun, 25 Apr 2010 18:03:28 +0000 (UTC) (envelope-from ltsampros@gmail.com) Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mx1.freebsd.org (Postfix) with ESMTP id EB0178FC15 for ; Sun, 25 Apr 2010 18:03:27 +0000 (UTC) Received: by bwz8 with SMTP id 8so10523376bwz.3 for ; Sun, 25 Apr 2010 11:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :references:date:in-reply-to:message-id:user-agent:mime-version :content-type; bh=j4N0jzAtxrSWPC1n/yVJ2/ows71dpxIsgtZwU6hMVgI=; b=gmCuxHwYEhPHMmUbKxIl+xXLhqosDRzKlbq7BdLSW+kgvKsc8uboq3FlHEY1iYsBiN zBKnfpCLRvFQ5p1c9LLPh1AJtm2uJ4J5svDmZWb0+6gKKakPhNn592xy82MMhViB8fRu KtKZD6UODex2XSPczNLBmhEj/BoZxuPM6XP94= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=tyTHGv7DkNEteXzBVoQPyJzSQMw/jcVHEbtE7df9fYFcAYEPK8s+TvFcF4z5A8guYw 05JReps5RNo0ZU5EFWuE78sABBf3ZS8ryNWLykhk+vO53zkMcNdTP/zuifBIJa1lkTui wfc7JAJOoJaITKdCIcDOkIxy9RcLemPCdZ2zk= Received: by 10.204.152.140 with SMTP id g12mr1823792bkw.130.1272218597704; Sun, 25 Apr 2010 11:03:17 -0700 (PDT) Received: from ltsampros-laptop.bifteki.lan (ppp089210204115.dsl.hol.gr [89.210.204.115]) by mx.google.com with ESMTPS id 13sm1200707bwz.11.2010.04.25.11.03.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 25 Apr 2010 11:03:17 -0700 (PDT) Sender: Leonidas Tsampros From: Leonidas Tsampros To: yuri@rawbw.com References: <4BD3E923.9030606@rawbw.com> Date: Sun, 25 Apr 2010 21:02:43 +0300 In-Reply-To: <4BD3E923.9030606@rawbw.com> (yuri@rawbw.com's message of "Sun, 25 Apr 2010 00:02:59 -0700") Message-ID: <87k4rvh0l8.fsf@upnet.gr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: Why system gcc that is 4.2.1 produces different code than gcc-4.2.1 compiled from sources? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Apr 2010 18:03:28 -0000 Yuri writes: > I ran this simple example: > > #include > #include > > int fib(int AnArg) { > if (AnArg <= 2) return (1); > return (fib(AnArg-1)+fib(AnArg-2)); > } > > int main(int argc, char* argv[]) { > int n = atoi(argv[1]); > printf("fib(%i)=%i\n", n, fib(n)); > } > > through system gcc and gcc built from sources. Both are 4.2.1. Options: -O3. > > Average runtime with the argument 45 is quite different: system gcc is > 3.650s and gcc-4.2.1 from sources is 3.740. > CPU: Intel(R) Core(TM) i7 CPU @ 9200 @ 2.67GHz > Hi, I'm pretty sure that a small difference in execution time does not mean that the produced code is different. In order to check the code gcc produced, you need to do something like this: objdump -d executable or even use gdb's disassemble command. Regards, Leonidas > Yuri