public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sgunderson at bigfoot dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49872] Missed optimization: Could coalesce neighboring memsets Date: Thu, 28 Jul 2011 10:10:00 -0000 [thread overview] Message-ID: <bug-49872-4-Hnt3kbr9zS@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-49872-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49872 --- Comment #2 from sgunderson at bigfoot dot com 2011-07-28 10:09:51 UTC --- I'm not sure if I've seen exactly this construction in real-world code, but I've certainly seen examples of the hybrid I sketched out (looking at one was what motivated me to file the bug), ie. something like: struct S { int f[1024]; int g; }; void func(struct S* s) { memset(s->f, 0, sizeof(s->f)); s->g = 0; } which I would argue should be rewritten to void func(struct S* s) { memset(s->f, 0, sizeof(s->f) + sizeof(s->g)); } I'd argue that programmers should not be doing this kind of optimization themselves, since it's very prone to break when changing the structure, especially as alignment etc. comes into play.
next prev parent reply other threads:[~2011-07-28 10:10 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-07-27 16:51 [Bug tree-optimization/49872] New: " sgunderson at bigfoot dot com 2011-07-28 10:01 ` [Bug tree-optimization/49872] " rguenth at gcc dot gnu.org 2011-07-28 10:10 ` sgunderson at bigfoot dot com [this message] 2021-08-21 23:57 ` pinskia at gcc dot gnu.org 2024-04-21 19:26 ` pinskia at gcc dot gnu.org
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: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-49872-4-Hnt3kbr9zS@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe 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).