public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57742] New: memset(malloc(n),0,n) -> calloc(n,1)
@ 2013-06-27 22:28 glisse at gcc dot gnu.org
  2013-10-11 16:44 ` [Bug tree-optimization/57742] " glisse at gcc dot gnu.org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-06-27 22:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57742
           Summary: memset(malloc(n),0,n) -> calloc(n,1)
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org

Hello,

calloc can sometimes be significantly faster than malloc+bzero because it has
special knowledge that some memory is already zero. When other optimizations
simplify some code to malloc+memset(0), it would thus be nice to replace it
with calloc. Sadly, I don't think there is a way to do a similar optimization
in C++ with new, which is where such code most easily appears (creating
std::vector<int>(10000) for instance). And there would also be the complication
there that the size of the memset would be a bit smaller than that of the
malloc (using calloc would still be fine, but it gets harder to know if it is
an improvement).


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

end of thread, other threads:[~2015-09-17 19:32 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-27 22:28 [Bug tree-optimization/57742] New: memset(malloc(n),0,n) -> calloc(n,1) glisse at gcc dot gnu.org
2013-10-11 16:44 ` [Bug tree-optimization/57742] " glisse at gcc dot gnu.org
2013-10-14  8:55 ` rguenth at gcc dot gnu.org
2013-10-14  9:51 ` Joost.VandeVondele at mat dot ethz.ch
2013-10-14 10:07 ` glisse at gcc dot gnu.org
2013-10-14 10:46 ` rguenth at gcc dot gnu.org
2013-10-14 11:48 ` glisse at gcc dot gnu.org
2013-10-14 20:51 ` glisse at gcc dot gnu.org
2013-10-14 20:53 ` glisse at gcc dot gnu.org
2013-10-15  7:57 ` rguenth at gcc dot gnu.org
2013-10-15 14:11 ` glisse at gcc dot gnu.org
2013-10-15 16:38 ` glisse at gcc dot gnu.org
2013-10-16 14:11 ` rguenth at gcc dot gnu.org
2014-02-22 15:44 ` glisse at gcc dot gnu.org
2014-02-23 18:46 ` glisse at gcc dot gnu.org
2014-06-24 19:04 ` glisse at gcc dot gnu.org
2014-06-25  6:46 ` Joost.VandeVondele at mat dot ethz.ch
2014-06-25  7:41 ` Joost.VandeVondele at mat dot ethz.ch
2014-06-25  7:53 ` glisse at gcc dot gnu.org
2014-06-25  8:09 ` glisse at gcc dot gnu.org
2014-06-25 12:27 ` glisse at gcc dot gnu.org
2014-06-25 12:29 ` glisse at gcc dot gnu.org
2015-09-17 19:32 ` daniel.gutson at tallertechnologies dot com

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