This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strict-aliasing and typedefs


On Wed, May 14, 2003 at 11:59:30PM +0200, Gabriel Dos Reis wrote:
> 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?

You're entirely correct, but I think that what Brad wanted (based on
his message) was:
  typedef int kindone;
  typedef int kindtwo;

and then to have any kindtwo* pointer not alias any kindone* pointer. 
Which is not quite the same as restrict, and is not possible in C.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]