From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6D37E3858408; Tue, 31 Aug 2021 11:54:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D37E3858408 From: "rearnsha at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102125] (ARM Cortex-M3 and newer) missed optimization. memcpy not needed operations Date: Tue, 31 Aug 2021 11:54:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rearnsha at gcc dot gnu.org 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2021 11:54:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102125 --- Comment #5 from Richard Earnshaw --- Testcase was not quite complete. Extending it to: typedef unsigned long long uint64_t; typedef unsigned long uint32_t; typedef unsigned char uint8_t; uint64_t bar64(const uint8_t *rData1) { uint64_t buffer; __builtin_memcpy(&buffer, rData1, sizeof(buffer)); return buffer; } uint32_t bar32(const uint8_t *rData1) { uint32_t buffer; __builtin_memcpy(&buffer, rData1, sizeof(buffer)); return buffer; } and then looking at the optimized tree output we see: ;; Function bar64 (bar64, funcdef_no=3D0, decl_uid=3D4196, cgraph_uid=3D1, symbol_order=3D0) uint64_t bar64 (const uint8_t * rData1) { uint64_t buffer; uint64_t _4; [local count: 1073741824]: __builtin_memcpy (&buffer, rData1_2(D), 8); _4 =3D buffer; buffer =3D{v} {CLOBBER}; return _4; } ;; Function bar32 (bar32, funcdef_no=3D1, decl_uid=3D4200, cgraph_uid=3D2, symbol_order=3D1) uint32_t bar32 (const uint8_t * rData1) { unsigned int _3; [local count: 1073741824]: _3 =3D MEM [(char * {ref-all})rData1_2(D)]; return _3; } So in the 32-bit case we've eliminated the memcpy at the tree level, but fa= iled to do that for 64-bit objects. We probably need to add 64-bit support to the movmisalign pattern.=