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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a34b7ad6c6a0774 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-xxxfer.readnews.com!news-out.readnews.com!transit4.readnews.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Fri, 13 Aug 2010 16:22:05 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1jn1a4o.1dfllwo1uin3imN%csampson@inetworld.net> <1jn36d6.se2f0g1edjjnyN%csampson@inetworld.net> <61f149b9-00ff-40cd-9698-01e69fdc5c0f@v15g2000yqe.googlegroups.com> <12ce49e6-169e-4e35-b82f-27de0d9b1ceb@t20g2000yqa.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1281730907 5092 192.74.137.71 (13 Aug 2010 20:21:47 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 13 Aug 2010 20:21:47 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:mg3pHk38gRXyJfA/OE6Z/2Ko9R0= Xref: g2news1.google.com comp.lang.ada:13243 Date: 2010-08-13T16:22:05-04:00 List-Id: Elias Salom�o Helou Neto writes: >> Anyway, someone prematurely implied that I may be doing premature >> optimization. The fact is that I do know, from profiling, how >> important is _not_ to range check in my specific application, so I >> will try to give you a "bottom line" of what have been said that >> really matters to me. >> >> 1) You can, in more than one way, tell the compiler to suppress most >> (any?) checks, but people do not advise to do so. Even if I say that I >> do need that :( Even if it's true that it is "important _not_ to range check", that does not necessarily mean that you need to suppress checks. As Dmitry pointed out, many checks will be removed by the compiler even if you don't suppress them -- it will remove the ones it can prove will not fail. The only way to determine whether that's good enough is to measure it, and/or look at the machine code. As for the advice you mention, if it said "Never suppress checks", it's bad advice. > ask for the suppression, but it does NOT mandate the compiler to > actually > skip such checks. ... Of course! That's true of all higher-level languages, including C. Higher-level language never formally define what machine code gets generated, nor how efficient it has to be -- there's no way to do so. A C compiler is allowed by the C standard to do array bounds checking, and I assure you that if such a C compiler exists, the checks are FAR more expensive than for Ada. The Ada RM has some informal rules, called "Implementation Advice" and "Implementation Requirements", and there's one in there somewhere saying compilers really ought to skip the checks when it makes sense. Don't worry, Ada compiler writers do not deliberately try to harm their customers -- of course they actually skip the checks when it makes sense. Note that it doesn't always make sense, since some checks are done for free by the hardware. - Bob