public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/9540: C99 initializers generate lots of code
@ 2003-05-13 13:26 Christian Ehrhardt
0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2003-05-13 13:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/9540; it has been noted by GNATS.
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: gcc-prs@gcc.gnu.org, mariube+gcc+@ifi.uio.no, gcc-bugs@gcc.gnu.org,
gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org
Cc:
Subject: Re: optimization/9540: C99 initializers generate lots of code
Date: Tue, 13 May 2003 15:17:39 +0200
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9540
The code size of the two functions differs because you do two
fundamentally different things:
* new_vector1 creates a compound literal (this is a separate object not
just an initializer!) of type string. The contents of this object
are then assigned to *result.
* new_vector2 initializes *result directly without the construction of
an intermediate compound literal.
The additional instructions that you see are the result of the copying
which is in general necessary because we can't know if gc_malloc might
rely on the memory in *result or might modify previously initialized
elements of the compound literal. The latter might be impossible
due to aliasing rules but I'm not entirly sure about this. The former
is definitely possible, e.g. if the first call to gc_malloc also stored
the return value in some static or global variable.
Given the fact that gcc does optimize the mem to mem copy away if
the compound literal is declared const and gc_malloc is called outside
of the initializer I guess that there aren't enough aliasing restrictions
to allow the optimization otherwise.
regards Christian
--
THAT'S ALL FOLKS!
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: optimization/9540: C99 initializers generate lots of code
@ 2003-02-03 21:02 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-02-03 21:02 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, mariube+gcc+, nobody
Synopsis: C99 initializers generate lots of code
State-Changed-From-To: feedback->open
State-Changed-By: bangerth
State-Changed-When: Mon Feb 3 21:02:25 2003
State-Changed-Why:
Feedback received. The sizes of the two functions are
indeed different, but I have too little knowledge of
the optimizers to analyze whether they differ in any
measurable quantity (run-time, clock-ticks), so leave
this to others.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9540
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-13 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-13 13:26 optimization/9540: C99 initializers generate lots of code Christian Ehrhardt
-- strict thread matches above, loose matches on Subject: below --
2003-02-03 21:02 bangerth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).