public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/21478] New: Improve initialization of sparse local arrays
@ 2005-05-09 22:15 jconner at apple dot com
  2005-05-09 22:16 ` [Bug middle-end/21478] " jconner at apple dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jconner at apple dot com @ 2005-05-09 22:15 UTC (permalink / raw)
  To: gcc-bugs

Large local arrays that are initialized to constant values, gcc uses a static template and a call to 
memcpy.  If these arrays are all or mostly zeroes, if we clear the array using memset and then initialize 
the non-zero values inline, it is generally better in two ways:
a) it is faster
b) it requires less program memory overhead to store the array of initializers

Here is an example of source code that gcc could do better on:

    void bar (char *);
    void foo (void)
    {
      char bigarray[0x1000] = { 0 };

      bar (&bigarray[0]);
    }

Which generates a 0x1000 byte constant array of zeroes.  Instead, it would be nice if gcc would just 
memset the region to zeroes.

This construct is used extensively in the FAAD2 open source AAC encoder/decoder library, resulting in 
a 35%+ increase in size.

AFAICT, this applies to all targets, not just ARM.

-- 
           Summary: Improve initialization of sparse local arrays
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jconner at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: powerpc-apple-darwin7.9.0
GCC target triplet: arm-none-elf


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-06-02 19:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09 22:15 [Bug middle-end/21478] New: Improve initialization of sparse local arrays jconner at apple dot com
2005-05-09 22:16 ` [Bug middle-end/21478] " jconner at apple dot com
2005-05-09 22:30 ` pinskia at gcc dot gnu dot org
2005-05-10  0:50 ` jconner at apple dot com
2005-05-17 17:25 ` pinskia at gcc dot gnu dot org
2005-06-01 21:34 ` cvs-commit at gcc dot gnu dot org
2005-06-02 19:17 ` pinskia at gcc dot gnu dot org

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).