From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4395D3857B87; Wed, 22 Nov 2023 14:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4395D3857B87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700665042; bh=I5cjTkvVNG9Pn9z8NjbLlKgzOTfYMKYAccVBk8oUdio=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mri+6AUmFwoJchE2K+1J466Jx6hKGgjwEciF3LXyfw0On5ifc6U+IwHryUV90/tlC GpJDTtMgzaAe7VXjpP0XRzBKItNUk/xPewANc0k363tFQy3uXF0GSptQNkvo8ZIM+U pAwhywIT52f+AqTa7ne3dEeEetB7EXWVPq1kBkmg= From: "bugdal at aerifal dot cx" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/32667] block copy with exact overlap is expanded as memcpy Date: Wed, 22 Nov 2023 14:57:19 +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: bugdal at aerifal dot cx 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 #26 from Rich Felker --- > The only reasonable fix on the compiler side is to never emit memcpy but = always use memmove. No, it can literally just emit (equivalent at whatever intermediate form of= ): cmp src,dst je 1f call memcpy 1: in place of memcpy. It can even optimize out that in the case where it's provable that they're = not equal, e.g. presence of restrict or one of the two objects not having had i= ts address taken/leaked.=