strict-aliasing and typedefs
Gabriel Dos Reis
gdr@integrable-solutions.net
Wed May 14 21:59:00 GMT 2003
Daniel Jacobowitz <drow@mvista.com> writes:
| On Wed, May 14, 2003 at 11:31:49PM +0200, Gabriel Dos Reis wrote:
| > Andreas Schwab <schwab@suse.de> writes:
| >
| > [...]
| >
| > | int *sp;
| > | int *hp;
| > |
| > | |> I'm wondering if a Scheme->C compiler
| > | |> can use typedefs and ISO C's aliasing rules to tell gcc that certain
| > | |> memory locations cannot alias each other.
| > |
| > | One way to do this is to define differently named structures with a single
| > | member, but they may pessimize the generated code due to ABI
| > | peculiarities.
| >
| > As I understand it, he would like an object-based non-alias
| > optimization, I believe restrict is a good candidate.
|
| That depends. Brad's initial example could also be used for type-based
| non-alias optimization, for different sets of int objects - which is
| somewhat looser than restrict allows.
I'm not sure I get what you meant.
At the type-level, one cannot distingush an int* from another int*,
they are both int* so may alias each other.
At the the object-level, where one considers different sets of objects
of the *same type*, one needs an additional information not provided
just by the type. What did I miss in your remark?
-- Gaby
More information about the Gcc
mailing list