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: TREE_UNCHANGING?


>>>>> "Jason" == Jason Merrill <jason@redhat.com> writes:

> Perhaps what I want is, rather, to tell the optimizer that the value will
> not change behind its back; that the assignments we can see are all there
> is.  That it can change, but cannot alias.

It seems that restrict provides this sort of guarantee; in this testcase,
can the compiler avoid doing two loads from *p?

  int i;
  void f ();
  void g (int *__restrict p)
  {
    int j = *p;
    f ();
    j += *p;
    i = j;
  }

6.7.3.1/4 seems to say that any lvalue used to modify *p during the
execution of g must be based on p.  Since f cannot name p, it can't create
such an lvalue, so we can assume that the call does not modify *p.  Right?

Jason


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