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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7af3eb61e15f9a0b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-17 19:00:39 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.sttln1.wa.home.com.POSTED!not-for-mail From: "DuckE" Newsgroups: comp.lang.ada References: <9t5ihf$dp$1@news.tpi.pl> <5ee5b646.0111171819.d56766d@posting.google.com> Subject: Re: pointer movement? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Sun, 18 Nov 2001 03:00:39 GMT NNTP-Posting-Host: 24.248.45.203 X-Complaints-To: abuse@home.net X-Trace: news1.sttln1.wa.home.com 1006052439 24.248.45.203 (Sat, 17 Nov 2001 19:00:39 PST) NNTP-Posting-Date: Sat, 17 Nov 2001 19:00:39 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:16665 Date: 2001-11-18T03:00:39+00:00 List-Id: I agree it is not a good idea to have roaming pointers. And go a step farther to preach my version of the rules of optimization (they're not orginal but I can't remember the source): Rule #1. Don't do it. Rule #2. Don't do it yet. Rule #3. Only optimize those parts of the program that need optimization. With the side not that typically 10% of the program runs 90% of the time. But... In my experience using GCC on an MVME162 (MC68040) under VxWorks, when I had to optimize certain time critical parts of code (a very small fraction of the overall code in the system), I found that sequencing through memory by incrementing pointers was somewhat faster than incrementing an array index and accessing the same memory by indexing the array. IMHO it is not obvious that either method would perform better. The only way to determine performance is through testing or detailed analysis of the generated code on the specific target architecture. Generally you are better off to write the code in an obvious manner and trust the compiler to be smarter than you are at generating optimal code (compilers often are). But when push comes to shove and you find that you are close to but not quite achieving the required performance, in some cases re-arranging the code will help. SteveD "Robert Dewar" wrote in message news:5ee5b646.0111171819.d56766d@posting.google.com... [snip] > > It is a fallacy that having roaming pointers C style > will improve efficiency. In fact, this sloppy use of > pointers often makes it impossible for a C compiler > to do proper aliasing analysis. Declare an array, > reference it in the obvious manner, and for the most > typical code, normal optimizations should bring you > back to at least the C code efficiency, and if you use > a compiler with good aliasing analysis, perhaps better.