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: restrict and char pointers


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


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