[Bug c/78408] C loop initial declarations generate wrong code

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 24 14:02:00 GMT 2016


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

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #10)
> (In reply to Jakub Jelinek from comment #9)
> > Note in the testcase a = (struct buf) {}, b = (struct buf) {} generates
> > significantly more efficient code than a = b = (struct buf) {} - the former
> > is 2x memset, the latter 1x memset + 1x memcpy.
> > So, shall we for large aggregates gimplify those differently as an
> > optimization?
> 
> I believe the gimplifier is not a good place to do optimization.  You can
> pattern-match
> 
>   memset (&a, ..., N);
>   memcpy (&b, &a, N);
> 
> and transform it to two times memset.

Even the *.optimized dump contains:
  b = {};
  a = b;
  d = {};
  c = d;
Can match.pd handle these, or would it need to be special folding code (where? 
gimple-fold.c, tree dse, what other passes have good framework for that)?


More information about the Gcc-bugs mailing list