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,25b9eb5c3a89bced X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!130.59.10.21.MISMATCH!kanaga.switch.ch!ezmp3.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: where exactly c++,c fail and Ada gets thru' Date: Fri, 28 Apr 2006 14:27:27 +0200 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: <1145852356.559455.222600@i39g2000cwa.googlegroups.com> <1145855124.720029.35280@t31g2000cwb.googlegroups.com> <1235818.stAph9vF03@linux1.krischik.com> <1146207623.635562.289570@i39g2000cwa.googlegroups.com> NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1146227246 23666 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla Thunderbird 1.0.8-1.4.1.SL (X11/20060424) X-Accept-Language: en-us, en In-Reply-To: <1146207623.635562.289570@i39g2000cwa.googlegroups.com> Xref: g2news2.google.com comp.lang.ada:3984 Date: 2006-04-28T14:27:27+02:00 List-Id: Martin Krischik wrote: > The point is - of corse - it that the semantic tree of the Ada > compiler contains the information that X will be in the range of (1 .. > 5) and then the optimizer can easily calculate that (1 .. 5) + 3 < 10 > and then optimize away the check. > > The sematinc tree of the C++ will contain the information that X is in > the range of (-2*32 .. +2*32-1) and that is a pretty useless > information to the optimizer. Except that the optimizer is not limited to use only this information. With the two example ranges (1..5 and 1..10) the result of inlining will be that the following operations - all operating on the single value - will be placed one after another: 1. compare against 5 2. add 3 3. compare against 10 It doesn't take a rocket scientist to deduce that the third operation has a dead branch and can be therefore eliminated. Of course, Ada provides more information to the compiler and the more information the compiler has, the wider are the optimization opportunities, therefore languages with richer type systems are easier to optimize. Nobody questions that. But this is very far from the optimization being guaranteed in Ada or impossible in C++ - neither is the case. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/