From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4922 invoked by alias); 1 Aug 2013 18:29:39 -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 4820 invoked by uid 48); 1 Aug 2013 18:29:36 -0000 From: "wschmidt at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58041] Unaligned access to arrays in packed structure Date: Thu, 01 Aug 2013 18:29:00 -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.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wschmidt at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: wschmidt 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-08/txt/msg00045.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58041 --- Comment #14 from Bill Schmidt --- (In reply to Bernd Edlinger from comment #13) > Hi, > > just one question, how about the -m[no-]unaligned-access option? > > If -munaligned-access had been given the code was almost right, > I mean AFAIK ldr/str should be handled in hardware but ldmia generates > an alignment exception and _may_ be emulated by an IRQ handler, > but that would not be very efficient. > > When -mno-unaligned-access is given any ldr/str on unaligned > addresses have to be avoided. Well, unfortunately -mno-unaligned-access does not provide any information to the middle end. It's all handled in the ARM back end. So without directly checking an ARM-specific option in the middle-end (evil), we don't have a good solution for that. That's how I initially started looking at STRICT_ALIGNMENT, which ARM and Sparc have in common. However, since this is supposed to be an optimization and it is common for misaligned memory accesses to suffer a penalty, I think it is better just to not "optimize" when the memory access is misaligned, and leave it to the target back ends to do their normal cleanups and workarounds.