This is the mail archive of the gcc-bugs@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]

[Bug optimization/14295] New: [tree-ssa] copy propagation for aggregates


This is a (possible?) enhancement request. 
There already is a testcase in the testsuite for this: 20031106-6.c

struct s
{
  char d;
  int a, b;
  double m;
};

struct s foo (struct s r)
{
  struct s temp_struct1;
  struct s temp_struct2;
  struct s temp_struct3;
  temp_struct1 = r;
  temp_struct2 = temp_struct1;
  temp_struct3 = temp_struct2;
  return temp_struct3;
}

The .optimized dump is: 

foo (r)
{
  double r$m;
  int r$b;
  int r$a;
  struct s temp_struct3;

<bb 0>:
  r$a = r.a;
  r$b = r.b;
  r$m = r.m;
  temp_struct3.d = r.d;
  temp_struct3.a = r$a;
  temp_struct3.b = r$b;
  temp_struct3.m = r$m;
  return temp_struct3;
}

It would be nice if it would be just "return r;"

SRA could take care of things like this, but that might be much more work, plus
it precludes from using more optimized memory copy sequences for 
aggregate copying instead of series of loads and store. 

BTW, the above code seems strange too, temporaries are created for r.a, r.b 
and r.m, but not for r.d 

Another compiler produces the following assembly:

        mov     eax, DWORD PTR $T552[esp-4]
        push    esi
        push    edi
        mov     ecx, 6
        lea     esi, DWORD PTR _r$[esp+4]
        mov     edi, eax
        rep movsd
        pop     edi
        pop     esi

-- 
           Summary: [tree-ssa] copy propagation for aggregates
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14295


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