Re: Stealing a Great Idea from the 6600

Liste des GroupesRevenir à c arch 
Sujet : Re: Stealing a Great Idea from the 6600
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.arch
Date : 19. Jun 2024, 22:24:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4vi9l$25m5b$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : slrn/1.0.3 (Linux)
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.

Date Sujet#  Auteur
13 Jun 24 * Re: Stealing a Great Idea from the 660031Kent Dickey
13 Jun 24 +* Re: Stealing a Great Idea from the 660016Stefan Monnier
13 Jun 24 i`* Re: Stealing a Great Idea from the 660015BGB
13 Jun 24 i `* Re: Stealing a Great Idea from the 660014MitchAlsup1
14 Jun 24 i  `* Re: Stealing a Great Idea from the 660013BGB
18 Jun 24 i   `* Re: Stealing a Great Idea from the 660012MitchAlsup1
19 Jun 24 i    +* Re: Stealing a Great Idea from the 66008BGB
19 Jun 24 i    i`* Re: Stealing a Great Idea from the 66007MitchAlsup1
19 Jun 24 i    i +* Re: Stealing a Great Idea from the 66005BGB
19 Jun 24 i    i i`* Re: Stealing a Great Idea from the 66004MitchAlsup1
20 Jun 24 i    i i `* Re: Stealing a Great Idea from the 66003Thomas Koenig
20 Jun 24 i    i i  `* Re: Stealing a Great Idea from the 66002MitchAlsup1
21 Jun 24 i    i i   `- Re: Stealing a Great Idea from the 66001Thomas Koenig
20 Jun 24 i    i `- Re: Stealing a Great Idea from the 66001John Savard
19 Jun 24 i    +- Re: Stealing a Great Idea from the 66001Thomas Koenig
20 Jun 24 i    +- Re: Stealing a Great Idea from the 66001MitchAlsup1
31 Jul 24 i    `- Re: Stealing a Great Idea from the 66001Lawrence D'Oliveiro
13 Jun 24 +* Re: Stealing a Great Idea from the 660013MitchAlsup1
13 Jun 24 i+* Re: Stealing a Great Idea from the 66005Stefan Monnier
13 Jun 24 ii+* Re: Stealing a Great Idea from the 66003MitchAlsup1
14 Jun 24 iii`* Re: Stealing a Great Idea from the 66002Terje Mathisen
14 Jun 24 iii `- Re: Stealing a Great Idea from the 66001MitchAlsup1
30 Jul 24 ii`- Re: Stealing a Great Idea from the 66001Lawrence D'Oliveiro
30 Jul 24 i`* Re: Stealing a Great Idea from the 66007Lawrence D'Oliveiro
30 Jul 24 i `* Re: Stealing a Great Idea from the 66006Michael S
31 Jul 24 i  `* Re: Stealing a Great Idea from the 66005Lawrence D'Oliveiro
31 Jul 24 i   `* Re: Stealing a Great Idea from the 66004Michael S
31 Jul 24 i    `* Re: Stealing a Great Idea from the 66003MitchAlsup1
1 Aug 24 i     `* Re: Stealing a Great Idea from the 66002Lawrence D'Oliveiro
1 Aug 24 i      `- Re: Stealing a Great Idea from the 66001MitchAlsup1
14 Jun 24 `- Re: Stealing a Great Idea from the 66001Terje Mathisen

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal