Re: Possible ANSI C Optimisation Done in Practice?

"David Thompson" <david.thompson1@worldnet.att.net>
3 Jan 2002 16:40:47 -0500

          From comp.compilers

Related articles
[12 earlier articles]
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2001-12-22)
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2001-12-24)
Re: Possible ANSI C Optimisation Done in Practice? nmm1@cus.cam.ac.uk (2001-12-24)
Re: Possible ANSI C Optimisation Done in Practice? toon@moene.indiv.nluug.nl (Toon Moene) (2001-12-24)
Re: Possible ANSI C Optimisation Done in Practice? nmm1@cus.cam.ac.uk (2001-12-27)
Re: Possible ANSI C Optimisation Done in Practice? david.thompson1@worldnet.att.net (David Thompson) (2001-12-27)
Re: Possible ANSI C Optimisation Done in Practice? david.thompson1@worldnet.att.net (David Thompson) (2002-01-03)
Re: Possible ANSI C Optimisation Done in Practice? ralph@inputplus.demon.co.uk (2002-01-05)
| List of all articles for this month |

From: "David Thompson" <david.thompson1@worldnet.att.net>
Newsgroups: comp.compilers
Date: 3 Jan 2002 16:40:47 -0500
Organization: AT&T Worldnet
References: 01-12-050 01-12-068 01-12-079
Keywords: optimize, comment
Posted-Date: 03 Jan 2002 16:40:47 EST

Ralph Corderoy <ralph@inputplus.demon.co.uk> wrote :
....
> t is initialised to point to tmp and is only ever incremented. Under
> ANSI C it's only valid to continue until t points to one char past the
> end of tmp. tmp is a local variable to the routine, s is a parameter
> passed in, so they can't overlap. Therefore writing to *t can't
> affect s. Surely, this kind of reasoning is made use of in a
> compiler, why else did ANSI `tighten' C with these kind of rules?


AIUI the _reason_ for the pointer arithmetic limitations was so C
could be (and was) implemented on a wide variety of platforms, some
not using the flat-linear-address model where you can safely compute
(if not use) any pointer value. It represents the minimum necessary
to make the BCPL-derived array semantics work, without requiring
additional functionality that would constrain implementations without
being really useful.


The fact that this can sometimes assist in aliasing analysis is mostly
a happy accident. As already noted, C99 does so more generally and
formally with 'restrict'; by your logic, this wouldn't have been added
if it weren't needed, right?
--
- David.Thompson 1 now at worldnet.att.net
[The non-flat target that people cared about was the 286, of course. Ugh.
But I know several of the people who have been on the various C committees
and they were certainly aware that the more they could limit wacky aliasing,
the more optimization they could do. -John]


Post a followup to this message

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