From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46548 invoked by alias); 27 Aug 2015 07:39:28 -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 46487 invoked by uid 48); 27 Aug 2015 07:39:23 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/67366] Poor assembly generation for unaligned memory accesses on ARM v6 & v7 cpus Date: Thu, 27 Aug 2015 07:39:00 -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: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth 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: bug_status cf_reconfirmed_on cc version everconfirmed 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-08/txt/msg01849.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67366 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-08-27 CC| |rguenth at gcc dot gnu.org Version|4.8.2 |6.0 Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- I think this boils down to the fact that memcpy expansion is done too late and that (with more recent GCC) the "inlining" done on the GIMPLE level is restricted to !SLOW_UNALIGNED_ACCESS but arm defines STRICT_ALIGNMENT to 1 unconditionally. I guess arm goes through the movmisalign optab for unaligned accesses and the GIMPLE inlining could be enabled as well if movmisalign is supported. Note that GCC 4.8 is no longer supported and enhancements will go to GCC 6 at most. With current trunk and -O2 -march=armv6 I get for typedef unsigned int u32; u32 read32(const void* ptr) { u32 v; __builtin_memcpy(&v, ptr, sizeof(v)); return v; } read32: @ args = 0, pretend = 0, frame = 8 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. ldr r0, [r0] @ unaligned sub sp, sp, #8 add sp, sp, #8 @ sp needed bx lr so apart from the stack slot not getting removed this has already improved, but the issue I mention still happens as we expand from read32 (const void * ptr) { u32 v; u32 _4; : __builtin_memcpy (&v, ptr_2(D), 4); _4 = v; v ={v} {CLOBBER}; return _4; so partially confirmed, for the GIMPLE memory op "inlining" issue.