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

            Bug ID: 123860
           Summary: VN result depends on unordered load order
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

struct X { int a; int b; } p, o;
void foo ()
{
  p = o;
  int pa = p.a;
  int oa = o.a;
  if (pa != oa)
    __builtin_abort ();
}

is not optimized but if we swap the two loads we can optimize because
p.a is translated though the copy p = o and the o.a load result is already
available.

We could iterate VARYING defs as long as some values change and the VUSE
stays the same.  But this sounds like a) possibly expensive and b) awkward?

Lowering the aggregate copy to a component-wise copy also allows
optimizing this.

Reply via email to