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: a07f3367d7,56525db28240414a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.96.42 with SMTP id dp10mr201719wib.2.1343094365913; Mon, 23 Jul 2012 18:46:05 -0700 (PDT) Path: ge7ni52415029wib.0!nntp.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!ramfeed-2.ams.xsnews.nl!feed.xsnews.nl!border-2.ams.xsnews.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!216.40.29.245.MISMATCH!novia!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!news.nctu.edu.tw!csnews.cs.nctu.edu.tw!news.cs.nctu.edu.tw!feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Efficient Sequential Access to Arrays Date: Mon, 16 Jul 2012 13:34:33 +0200 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <87394saqie.fsf@adaheads.sparre-andersen.dk> References: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> <44f2bfd0-75ed-4b9c-982e-61d5308f9c01@googlegroups.com> NNTP-Posting-Host: 79.138.241.140.bredband.3.dk Mime-Version: 1.0 X-Trace: munin.nbi.dk 1342438477 17850 79.138.241.140 (16 Jul 2012 11:34:37 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 16 Jul 2012 11:34:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:2bAeEOXeElXKfTkEYURtgt3L46E= X-Original-Bytes: 1852 Content-Type: text/plain; charset=us-ascii Date: 2012-07-16T13:34:33+02:00 List-Id: Keean Schupke wrote: > for J in S .. E loop > Y := Y + X(J).Z; > end loop; > > Where S and E are random numbers in the index range of the array and > where S < E, and the array is an array of records (in this case 28 > bytes long) containing the integer Z. > > imul $0x1c,%r9,%r10 > add 0x48(%rsp,%r10,1),%edi > > So you can see the multiplication is executed for every iteration. Your example is probably too simple for your actual application, but (in Ada 2012) you could also write it (untested): for J of X (S .. E) loop Y := Y + J.Z; end loop; Greetings, Jacob -- "Never interrupt your enemy when he is making a mistake."