From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 324A53858421; Thu, 23 Nov 2023 20:27:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 324A53858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700771268; bh=KFm0k3g6juV7v1oDFwieZFQFAGm4VaMQdBwmHZkgquY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nYGBu2m5O0YuI+j9ZHMKHfCqluInFkin2yWe8SkKfNyflLrfhyjL7F17WGxks9jpF Mp1Ql6PK1ajI8/E8SRDX3NmrlKOdMnAr8DCr2bIWEBvzXow3JfdAi09dbwmoa/H8/H Zsyl7QW35v26IRO2gE01LNF81vcLdw/Qju6SYlgc= 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: Thu, 23 Nov 2023 20:27:47 +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 #44 from Rich Felker --- My naive expectation is that "if ((uintptr_t)src =3D=3D 0x400400)" is and s= hould be UB, but I may be misremembering the details of the formalism by which the s= pec for restrict is implemented. If so, that's kinda a help, but I still think you would want to remove rest= rict from the arguments and apply it later, so that the fast-path head/tail copi= es can avoid any branch, and the check for equality can be deferred until it's known that there's a "body remainder" to copy. That's the part where you re= ally want the benefits of restrict anyway -- without restrict it's not vectoriza= ble because the compiler has to assume there might be nonexact overlap, in which case reordering the loads and stores in any way could change the result.=