From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22398 invoked by alias); 14 Mar 2013 21:36:13 -0000 Received: (qmail 20896 invoked by uid 48); 14 Mar 2013 21:35:56 -0000 From: "eleventen at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/56620] Memcpy optimization may lead to unaligned access on ARM Thumb Date: Thu, 14 Mar 2013 21:36: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-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eleventen at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 X-SW-Source: 2013-03/txt/msg01108.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56620 --- Comment #6 from Marc Singer 2013-03-14 21:= 35:54 UTC --- For the sake of posterity, the Cortex-M3 and M4 do handle unaligned accesses properly in hardware though with the expected performance penalty. It is t= he fact that I enforced alignment by making configuration changes to the MCU t= hat caused the issue. And I did so on the recommendation of ARM which isn't universally justified in the Cortex TRM: To ensure a smooth transition, ARM recommends that code designed to operate= on other Cortex-M profile processor architectures obey the following rules and configure the Configuration and Control Register (CCR) appropriately: =E2=80=A2 =E2=80=A2 =E2=80=A2 use word transfers only to access registers in the NVIC and System Control Space (SCS). treat all unused SCS registers and register fields on the processor as Do-Not-Modify. configure the following fields in the CCR: =E2=80=94 STKALIGN bit to 1 =E2=80=94 UNALIGN_TRP bit to 1 =E2=80=94 Leave all other bits in the CCR register as their original value.