From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,103803355c3db607 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.196.232 with SMTP id ip8mr6459395pbc.6.1342336539453; Sun, 15 Jul 2012 00:15:39 -0700 (PDT) Path: l9ni11846pbj.0!nntp.google.com!news1.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: GNAT (GCC) Profile Guided Compilation Date: Sun, 15 Jul 2012 10:15:35 +0300 Organization: Tidorum Ltd Message-ID: References: <38b9c365-a2b2-4b8b-8d2a-1ea39d08ce86@googlegroups.com> <982d531a-3972-4971-b802-c7e7778b8649@googlegroups.com> <520bdc39-6004-4142-a227-facf14ebb0e8@googlegroups.com> <4ff08cb2$0$6575$9b4e6d93@newsspool3.arcor-online.net> <4ff1d731$0$6582$9b4e6d93@newsspool3.arcor-online.net> <4ff41d38$0$6577$9b4e6d93@newsspool3.arcor-online.net> <26b778c4-5abc-4fbf-94b0-888c2ce71831@googlegroups.com> <4ff43956$0$6576$9b4e6d93@newsspool3.arcor-online.net> <2dba1140-4f28-4fb8-ace4-2c10f3a02313@googlegroups.com> Mime-Version: 1.0 X-Trace: individual.net 2fFDziT+iWJTEPIqHcAoBQoeR6w5srvRx4CRaiilr8/YEAU6zpImGR/LO9SzWM3CDe Cancel-Lock: sha1:SLkYDY8MwaBrE8BZdur0+EV+dA4= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-07-15T10:15:35+03:00 List-Id: On 12-07-15 02:40 , Keean Schupke wrote: > After a bit of checking line-by-line to make sure I am using 'and > then', 'or else' and 'constant' everywhere I can in the code, Ada is > outperforming C++ when using profile-guided compilation for the first > time. both C++ and Ada are getting about 40k simulations per second > with normal compilation, C++ is achieving 56k simulations per second > profile-guided, and Ada 57k per second. Good news. An Ada copmiler is of course free to implement the ordinary "long-circuit" operators "and"/"or" using short-circuit code, if the evaluation of the operands has no side effects. What are the operands typically like in your program? Are they function calls, or simple variables? It seems to me that the general belief, regarding the expected relative speeds of the short-circuit code versus the long-circuit code for Boolean expressions with simple operands, is that the branch penalties on modern processors are so large that the short-circuit form is not obviously faster. This may explain why the Ada compiler is not using the short-circuit code automatically. Clearly, if the expression is "(simple operand likely to be True) and (longer and longer expression)", at some point the short-circuit code (or changing to "and then") will become faster than the long-circuit code, whatever the branch penalty. This point will come sooner if profile-guidance is used to reduce the branch penalty. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .