restrict and char pointers
James E Wilson
wilson@specifixinc.com
Wed May 4 20:47:00 GMT 2005
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
here.
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
More information about the Gcc
mailing list