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,acba876b1e3c9639 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 17 May 2007 22:03:26 +0200 From: Gautier User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GNAT Optimization of Constant Expressions References: <1179355028.624745.258370@q75g2000hsh.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 83.77.165.50 X-Original-NNTP-Posting-Host: 83.77.165.50 Message-ID: <464cb4cd$1_3@news.bluewin.ch> X-Trace: news.bluewin.ch 1179432141 83.77.165.50 (17 May 2007 22:02:21 +0200) Organization: Bluewin AG Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 Path: g2news1.google.com!news1.google.com!news.glorb.com!wn13feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.bluewin.ch!not-for-mail Xref: g2news1.google.com comp.lang.ada:15821 Date: 2007-05-17T22:03:26+02:00 List-Id: Randy: [a brilliant dissertation about optimization] > After all, your original code is written to make a bunch of very expensive > calls ("Sin(0.5)", for instance) many times. Expecting the compiler to > remove those calls is asking a lot; I agree for any function call, but in the special case of functions from Generic_Elementary_Functions, it is _not_ asking a lot! A decent compiler should perform optimizations around these functions as well as around arithmetic operators. > it is much better to avoid making extra > calls with appropriate constant declarations. (I'd have that advice for any > language; why force the optimizer to work hard and possibly fail??) Obviously, there are compilers where the optimizer is working hard for the programmer, and other ones where the programmer has to work hard to make the optimizer work! ______________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/index.htm Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!