Deutsch English Français Italiano |
<v4vi9l$25m5b$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thomas Koenig <tkoenig@netcologne.de> Newsgroups: comp.arch Subject: Re: Stealing a Great Idea from the 6600 Date: Wed, 19 Jun 2024 21:24:05 -0000 (UTC) Organization: A noiseless patient Spider Lines: 54 Message-ID: <v4vi9l$25m5b$1@dont-email.me> References: <lge02j554ucc6h81n5q2ej0ue2icnnp7i5@4ax.com> <v02eij$6d5b$1@dont-email.me> <152f8504112a37d8434c663e99cb36c5@www.novabbs.org> <v04tpb$pqus$1@dont-email.me> <v4f5de$2bfca$1@dont-email.me> <jwvzfrobxll.fsf-monnier+comp.arch@gnu.org> <v4f97o$2bu2l$1@dont-email.me> <613b9cb1a19b6439266f520e94e2046b@www.novabbs.org> <v4hsjk$2vk6n$1@dont-email.me> <6b5691e5e41d28d6cb48ff6257555cd4@www.novabbs.org> Injection-Date: Wed, 19 Jun 2024 23:24:05 +0200 (CEST) Injection-Info: dont-email.me; posting-host="37742d36cd528af263d677a39e483ae4"; logging-data="2283691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UiZEwibLShMppTUJqKo03O0sduBQ1B9E=" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:YZjJ7OGwwCFxWQLf9eEeUb3gLdo= Bytes: 2749 MitchAlsup1 <mitchalsup@aol.com> schrieb: > One of the things we found in Mc 88120 was that the compiler should > NEVER > be allowed to put unnecessary instructions in decode-execute slots that > were unused--and that almost invariable--the best code for the GBOoO > machine was almost invariably the one with the fewest instructions, and > if several sequences had equally few instructions, it basically did not > matter. > > For example:: > > for( i = 0; i < max, i++ ) > a[i] = b[i]; > > was invariably faster than:: > > for( ap = &a[0], bp = & b[0];, i = 0; i < max; i++ ) > *ap++ = *bp++; > > because the later has 3 ADDs in the loop wile the former has but 1. > Because of this, I altered my programming style and almost never end up > using ++ or -- anymore. Interesting. I looked at a variant of this, void foo (int *a, int *b, int n) { int i; for( i = 0; i < n; i++ ) a[i] = b[i] + 1; } void bar (int *a, int *b, int n) { int *ap, *bp; int i; for( ap = &a[0], bp = & b[0], i = 0; i < n; i++ ) *ap++ = (*bp++) + 1; } I would expect ivopt to optimize these to the same assembly. Gcc does so, at least for AMD64 and POWER, and so does clang for the usual architectures if translated with -O2 -fno-unroll-loops -fno-tree-vectorize. But I think there are other reasons to chose the array version, I think - clarity is one of them, the other being uses of "restrict" on arguments.