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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-28 07:20:44 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp.abs.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Wed, 28 Jan 2004 10:20:37 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: In-Out Parameters for functions References: <1075159458.149886@master.nyc.kbcfp.com> <1075225041.167448@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1075303237.975898@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1075303238 23026 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:5001 Date: 2004-01-28T10:20:37-05:00 List-Id: Dmitry A. Kazakov wrote: > for I in A'Range loop > Sum := Sum + A (I) + B (I - A'First + B'First); > end loop; For code like this, I would expect the compiler to be generating all sorts of induction variables. There's never going to be a loop constant to hoist. The generated code should look something like this (in C): n = A_Last - A_First + 1; if (B_Last - B_First + 1 < n) raise Program_Error; pa = &A[A_First]; pb = &B[B_First]; while (n-- > 0) sum += *pa++ + *pb++; In any case, the compiler would be free to rearrange its calculations any way it likes as long as the results are the same as doing them in the proper order. If the compiler cannot determine that this is the case, then the code is probably tricky enough such that doing it in the defined order is helpful.