Re: small C++ classes

Shankar Unni <>
19 Dec 1997 00:15:41 -0500

          From comp.compilers

Related articles
small C++ classes (Werner Geurts) (1997-12-12)
Re: small C++ classes (Jason Merrill) (1997-12-13)
Re: small C++ classes (Jason Merrill) (1997-12-15)
Re: small C++ classes (Shankar Unni) (1997-12-19)
| List of all articles for this month |

From: Shankar Unni <>
Newsgroups: comp.compilers
Date: 19 Dec 1997 00:15:41 -0500
Organization: Powertel Global, Inc.
References: 97-12-097
Keywords: C++, optimize

Werner Geurts wrote:

> I am looking for information on storage allocation for small C++
> classes like point or complex, that contain only a few scalar data
> members. Are there any C++ compilers that allocate (the members of)
> such object to the register set instead of to memory? Under what
> conditions can this be done? During which compilation step can this
> be done?

> I am looking for pointers to papers or other resources that describe
> this optimisation.

Several compilers do some form of this optimization. Many split small
structures with simple layouts (one or two word-size fields) into
individual values when passing the structure by value. This also applies
to simple C++ classes like "complex", and to Fortran (-90?) structures
as well.

Likewise, such objects can also be kept in registers for their lifetime
with some basic analysis.

The KAI compiler does these things, as does SGI's 7.x compilers that I
know of, and quite probably many others as well..

Benchmarks like OOPACK test these styles of optimizations on typical
"value" classes.

Shankar Unni Powertel Global, Inc.
(650) 259-1700
(650) 259-1702 (fax)


Post a followup to this message

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