From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4675 invoked by alias); 28 Jul 2011 10:10:27 -0000 Received: (qmail 4664 invoked by uid 22791); 28 Jul 2011 10:10:26 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Jul 2011 10:10:11 +0000 From: "sgunderson at bigfoot dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49872] Missed optimization: Could coalesce neighboring memsets X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: sgunderson at bigfoot dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 28 Jul 2011 10:10:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg02447.txt.bz2 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.