public inbox for
help / color / mirror / Atom feed
From: "Christian Ehrhardt" <>
Subject: Re: optimization/9540: C99 initializers generate lots of code
Date: Tue, 13 May 2003 13:26:00 -0000	[thread overview]
Message-ID: <> (raw)

The following reply was made to PR optimization/9540; it has been noted by GNATS.

From: "Christian Ehrhardt" <>
Subject: Re: optimization/9540: C99 initializers generate lots of code
Date: Tue, 13 May 2003 15:17:39 +0200
 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

             reply	other threads:[~2003-05-13 13:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-13 13:26 Christian Ehrhardt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-02-03 21:02 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).