From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3BDD43858C2A; Thu, 23 Nov 2023 07:44:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BDD43858C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700725476; bh=nxJ+NbeqZQxK50qeQQYWZCaIxKKuIMtdDmLMidBUnA0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iUEXwm3345Ta5bf2acXfwG6iWkK6ywvQ5slF4uaQ0hrQxZAFHaT6E/DMHf/PeY7GY uETWKZluP5NAdxHKrHV1QFE50Nmz3XbrJuwV0Lw2LrpuYJJPTfYqSA7d06EL5CRw02 KSj81nAP0RFBeiDy8jpAKXu9dKrcG1VxDQ73bKQY= From: "post+gcc at ralfj dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/32667] block copy with exact overlap is expanded as memcpy Date: Thu, 23 Nov 2023 07:44:33 +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: post+gcc at ralfj dot de 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D32667 --- Comment #30 from post+gcc at ralfj dot de --- There have been several assertions above that a certain way to solve this either has no performance cost at all or severe performance cost. That soun= ds like we are missing data -- ideally, someone would benchmark the actual cos= t of emitting that branch. It seems kind of pointless to just make assertions ab= out the impact of this change without real data. > On the other hand, expecting the libc memcpy to make this check greatly p= essimizes every reasonable small use of memcpy with a gratuitous branch for= what is undefined behavior and should never appear in any valid program. I don't think this is true. As far as I can see, the performance impact of having memcpy support the src=3D=3Ddest case is zero -- the assembly genera= ted by the current implementations already supports that case. (At least I have not seen any evidence to the contrary.) No new check in memcpy is required.=