This is the mail archive of the
mailing list for the GCC project.
Re: restrict and char pointers
- From: James E Wilson <wilson at specifixinc dot com>
- To: Jeroen Dobbelaere <jeroen dot dobbelaere at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 04 May 2005 13:29:15 -0700
- Subject: Re: restrict and char pointers
- References: <firstname.lastname@example.org>
Jeroen Dobbelaere wrote:
void test_2(unsigned long* __restrict__ bar, char* __restrict__ bas)
unsigned long tmp = *bar;
*bas = 0;
*bar = tmp;
The optimization in the first example happens in the postreload cse
pass, and is relying on RTL alias analysis info.
The optimization does not happen for this example because we apparently
have no way to represent an alias set for a restricted char pointer.
char * and void * are allowed to alias anything. That is alias set 0
internally. A restricted char pointer can alias anything except another
restricted pointer, which would require making a subset of alias set 0,
but that is invalid. So we give up and just ignore the use of restrict
See in alias.c, where it does
if (pointed_to_alias_set == 0)
/* It's not legal to make a subset of alias set zero. */
DECL_POINTER_ALIAS_SET (decl) = 0;
We also don't handle restricted pointers to aggregate types.
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com