Re: Writing fast compilers... RS/6000

pardo@gar.cs.washington.edu (David Keppel)
Sat, 17 Aug 91 00:52:43 GMT

          From comp.compilers

Related articles
Re: Writing fast compilers... RS/6000 roger@gimli.inmos.co.uk (1991-08-16)
Re: Writing fast compilers... RS/6000 pardo@gar.cs.washington.edu (1991-08-17)
Re: Writing fast compilers... RS/6000 pcg@aber.ac.uk (1991-08-19)
| List of all articles for this month |

Newsgroups: comp.compilers
From: pardo@gar.cs.washington.edu (David Keppel)
Keywords: optimize
Organization: Computer Science & Engineering, U. of Washington, Seattle
References: <1991Aug15.010352.1@watt.ccs.tuns.ca> 91-08-068
Date: Sat, 17 Aug 91 00:52:43 GMT

>|>[Optimizing compilers won't do as much on well-written code because
>|> of e.g., common subexpression elimination in the source.]


roger@gimli.inmos.co.uk (Roger Shepherd) writes:
>Well, it depends on what you mean by ``well written code''.


Ah, yes, that reminds me of a code fragment that multiplies every
element of an array by either zero or one, then performs the desired
computation on the array. Result values that are zero are discarded
implicitly because sum+0==sum.


        /* Does this. */
        for (i=0; i<N; ++i)
            sum += compute(a[i]) * zero_or_one[i];


        /* Instead of this. */
        for (i=0; i<N; ++i)
            if (cond[i])
sum += compute(a[i]);


On `normal' machines it runs slower, on a Cray it runs faster. Ok,
who's to decide what `well written code' means?


;-D oN ( Well, written at any rate ) Pardo
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.