Re: Languages that give "hints" to the compiler

rfg@netcom.com (Ronald F. Guilmette)
Wed, 3 Aug 1994 07:14:56 GMT

          From comp.compilers

Related articles
Languages that give "hints" to the compiler jhummel@cy4.ICS.UCI.EDU (Joe Hummel) (1994-07-18)
Re: Languages that give "hints" to the compiler wisej@acf4.nyu.edu (1994-07-29)
Re: Languages that give "hints" to the compiler tgl@netcom.com (1994-07-19)
Re: Languages that give "hints" to the compiler jfisher@hplabsz.hpl.hp.com (1994-07-21)
Re: Languages that give "hints" to the compiler rfg@netcom.com (1994-07-31)
Languages that give "hints" to the compiler ssimmons@convex.com (1994-08-01)
Re: Languages that give "hints" to the compiler jls@summit.novell.com (1994-08-02)
Re: Languages that give "hints" to the compiler rfg@netcom.com (1994-08-03)
| List of all articles for this month |
Newsgroups: comp.compilers
From: rfg@netcom.com (Ronald F. Guilmette)
Keywords: C, C++, optimize
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: 94-07-066 94-08-014
Date: Wed, 3 Aug 1994 07:14:56 GMT
Status: RO

> Now to tell the truth, I know of no C or C++ compilers that currently make
> use of const qualification in this way, but I keep hoping. (If anyone
> else knows of compilers that *do* use const qualification in the manner
> I've described, please let me know.) Evidence of my hope may be seen
> frequently in my own (recent) code, which is littered with stuff with
> looks roughly like the following (for example):


ssimmons@convex.com (Steve Simmons) writes:
>The const qualifier is great; however, it would be a bad optimizer that
>would key purely off the const qualifier. Why???? Const can be coerced/cast
>away. Look at the following C++ code...


Please note that:


a) I never suggested that optimization pases of compilers should `key
        purely off the const qualifier'. In fact, what I had suggested was
        that proper attention to const qualifiers (on the part of a compiler)
        *should* cause very good code to be produced (if the programmer has
        written his code carefully) even when optimization is NOT requested
        for a given compile step.


b) The point you have raised about casting away const is rather completely
        irrelevant to the coding techniques I suggested in my earlier posting
        because, as shown in your own example, the issues raised by casting
        away const qualification only arise in the context of *pointers*, and
        (in C at least) there can never be any pointers which point to variables
        declared as `register', as in my examples. (I also covered this point
        briefly at the end of my earlier posting.)




P.S. I may have misspoke in my earlier posting in one small respect. I
bemoaned the apparent lack of C/C++ compilers which take account of const
qualification in the manner I described. I have since been informed that
the Metaware C compiler does in fact pay more attention to const qualifi-
cation that the average C compiler. However this information came to me
via a source which may perhaps be somewhat less than fully impartial (i.e.
an employee of Metaware). I myself have no way of personally verifying
this information, or of checking that examples such as the one in my prior
posting are indeed compiled (by Metaware C) into the kind of very
efficient code that I described. But the information certainly sounds
promising, and I would encourage anyone interested in this sort of
intelligence (on the part of C compilers) to perform their own independent
tests.


-- Ron Guilmette, Sunnyvale, CA ---------- RG Consulting -------------------
---- domain addr: rfg@netcom.com ----------- Purveyors of Compiler Test ----
---- uucp addr: ...!uunet!netcom!rfg ------- Suites and Bullet-Proof Shoes -
--


Post a followup to this message

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