Related articles |
---|
Does Duff Device break C compilers Lambert.Lum@eng.efi.com (Lambert Lum) (1996-05-06) |
Re: Does Duff Device break C compilers preston@tera.com (1996-05-07) |
Re: Does Duff Device break C compilers krste@ICSI.Berkeley.EDU (1996-05-08) |
Re: Does Duff Device break C compilers jeremy@floyd.sw.oz.au (1996-05-10) |
Re: Does Duff Device break C compilers rankin@eql.caltech.edu (1996-05-10) |
Re: Does Duff Device break C compilers msb@sq.com (1996-05-10) |
Re: Does Duff Device break C compilers preston@tera.com (1996-05-13) |
Re: Does Duff Device break C compilers baynes@ukpsshp1.serigate.philips.nl (1996-05-19) |
From: | rankin@eql.caltech.edu (Pat Rankin) |
Newsgroups: | comp.compilers |
Date: | 10 May 1996 01:33:11 -0400 |
Organization: | California Institute of Technology |
References: | 96-05-050 96-05-054 96-05-057 |
Keywords: | C, optimize |
preston@tera.com (Preston Briggs) writes:
: Better is to rewrite it, like this
: /* no assumptions made about count */
: for (n = 0; n < count; n++)
: to[n] = from[n];
: which is correct, obvious, maintainable, parallelizable, vectorizable,
: software pipelinable, and in all other ways superior. Well, I guess
: it doesn't have a fancy name. You may call it "Preston's Ploy" if
: that helps.
krste@ICSI.Berkeley.EDU (Krste Asanovic) writes:
> Better yet, "Krste's Kopy" :-)
> memcpy(from, to, count*(sizeof *from));
I wouldn't ordinarily comment on something like this, but I find
it highly ironic that both of these "obviously correct improvements"
fail to reimplement the original code, and produce entirely different
results. The first of these two could be easily fixed (use `to[0]',
and give up any hope of parallelization), but the second cannot be
used to replace Duff's Device.
And early versions of Digital's VAX C for VMS (probably the
Ultrix version too, but I never used that) refused to compile Duff's
Device, giving error messages claiming to the effect that case labels
were only allowed in switch statements, evidently confused by the
nesting. (Later versions got it right, and VAX C has long since been
replaced by DEC C.)
Pat Rankin, rankin@eql.caltech.edu
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.