From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16167 invoked by alias); 22 Feb 2015 13:48:35 -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 16126 invoked by uid 48); 22 Feb 2015 13:48:31 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64306] [SH] Improve unaligned loads and stores Date: Sun, 22 Feb 2015 14:44: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: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: NEW 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 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-02/txt/msg02427.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64306 Oleg Endo changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-02-22 Ever confirmed|0 |1 --- Comment #2 from Oleg Endo --- When storing bswapped values to unaligned mems the following happens: union unaligned32s { int val; } __attribute__((packed)); void store_32s_0 (unsigned char* x, unsigned char a, int b) { ((union unaligned32s*)(x))->val = a; } mov #0,r0 extu.b r5,r5 mov.b r0,@(1,r4) mov.b r0,@(2,r4) mov r5,r0 // r0 = zero (redundant load) shlr16 r0 // 0 >> 16 (redundant shift) mov.b r5,@r4 shlr8 r0 // 0 >> 8 (redundant shift) rts mov.b r0,@(3,r4) should be: mov.b r5,@r4 mov #0,r0 mov.b r0,@(1,r4) mov.b r0,@(2,r4) mov.b r0,@(3,r4) void store_32s_1 (unsigned char* x, unsigned char a, int b) { ((union unaligned32s*)(x))->val = __builtin_bswap32 (a); } extu.b r5,r5 swap.b r5,r5 swap.w r5,r5 extu.b r5,r1 mov.b r1,@r4 mov #0,r1 mov r1,r0 mov.b r0,@(1,r4) mov.b r0,@(2,r4) mov r5,r0 shlr16 r0 shlr8 r0 rts mov.b r0,@(3,r4) should be: mov #0,r0 mov.b r0,@(0,r4) mov.b r0,@(1,r4) mov.b r0,@(2,r4) mov r5,r0 mov.b r0,@(3,r4) A similar thing happens when storing the T bit to unaligned mems, see also PR 65162.