[Bug tree-optimization/69935] load not hoisted out of linked-list traversal loop

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Feb 24 04:24:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69935

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|load not skinked out of     |load not hoisted out of
                   |linked-list traversal loop  |linked-list traversal loop

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Full testcase (not needing the link; just in case it goes down):

struct foo {
  struct foo *n;
  int a;
};
struct foo_head {
  struct foo*h;
};


int traverse(struct foo_head *ph)
{
  int a = -1;
  struct foo *p, *pprev;
  pprev = p = ph->h;
  while (p) {
    pprev = p;
    p = p->n;
  }
  if (pprev)
    a = pprev->a;
  return a;
}

int traverse_loadloop(struct foo_head *ph)
{
  int a = -1;
  struct foo *p = ph->h;
  while (p) {
    a = p->a;
    p = p->n;
  }
  return a;
}


More information about the Gcc-bugs mailing list