From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98003 invoked by alias); 28 Sep 2015 18:18:50 -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 Received: (qmail 97941 invoked by uid 48); 28 Sep 2015 18:18:47 -0000 From: "hugh at mimosa dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/32667] block copy with exact overlap is expanded as memcpy Date: Mon, 28 Sep 2015 18:18:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hugh at mimosa dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg02219.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667 D. Hugh Redelmeier changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hugh at mimosa dot com --- Comment #12 from D. Hugh Redelmeier --- JJ in #11 is right. The compiler should never generate calls to functions with names in the user's space. That's because the user is allowed to (re)define anything with those names and is not constrained to preserve expected semantics. There should be a function in the reserved-to-system namespace that does what is needed. GCC should then call this function. Let's say that GCC uses __memcpy. The default standard definition of memcpy could be a synonym (until redefinition) for __memcpy. On the other hand, there are compile-time constraints on struct assignments that could yield even better performance. For example, GCC might know that the object is a multiple of 8 bytes, aligned on an 8-byte boundary. GCC would certainly know that the struct's length is non-zero, conceptually eliminating one test. This suggests implementing specialized variants, perhaps having names starting with __struct_assign. (I know GCC has an extension allowing 0 length objects. The assignment for such objects could be eliminated.)