Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!uwmcsd1!ig!agate!ucbvax!decwrl!labrea!polya!rokicki
From: rokicki@polya.Stanford.EDU (Tomas G. Rokicki)
Newsgroups: comp.sys.amiga
Subject: Re: PDC CrossDev Rel.3
Message-ID: <3270@polya.Stanford.EDU>
Date: 16 Jul 88 21:32:42 GMT
References: <42600029@uicsrd.csrd.uiuc.edu>
Reply-To: rokicki@polya.Stanford.EDU (Tomas G. Rokicki)
Organization: Stanford University
Lines: 59

Just a minor nit:

> 1) Strength reduction for double precision expressions,
> e.g. X*1 -> X, X*0 -> 0

This is peephole, not strength reduction.  Strength reduction
transforms loops as in the following piece of code:

     long a[] ;
     for (i=0; i<10; i++)
        a[i] = 0 ;

goes to the pseudocode

     i = 0 ;
loop:if !(i < 10) goto end ;
     t1 = i * 4 ;
     t2 = a + t1 ;
     *t2 = 0 ;
     i = i + 1 ;
     goto loop ;
end:

Here it is noticed that `t1' tracks the loop counter with the
expression (t1 = i * 4), which starts at 0, so the loop is changed
to:

     i = 0 ;
     t1 = 0 ;
loop:if !(i < 10) goto end ;
     t2 = a + t1 ;
     *t2 = 0 ;
     i = i + 1 ;
     t1 = t1 + 4 ;
     goto loop ;
end:

Note that a multiplication has been replaced by an addition.  Although,
in reality, it would be noticed that `t2' tracks i with the expression
(t2 = a + i * 4), so t1 would go away, yielding the resulting code

     i = 0 ;
     t2 = a ;
loop:if !(i < 10) goto end ;
     *t2 = 0 ;
     i = i + 1 ;
     t2 = t2 + 4 ;
     goto loop ;
end:

Now, a good C programmer might write this as

{
   long *t2 ;

   for (i=0, t2=a; i<10; i++, t2++)
      *t2 = 0 ;
}

but that's not the point.