From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17429 invoked by alias); 9 Aug 2012 21:55:12 -0000 Received: (qmail 17419 invoked by uid 22791); 9 Aug 2012 21:55:10 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Aug 2012 21:54:43 +0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54089] [SH] Refactor shift patterns Date: Thu, 09 Aug 2012 21:55: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: enhancement X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: olegendo at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC 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" 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: 2012-08/txt/msg00526.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54089 Oleg Endo changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kkojima at gcc dot gnu.org --- Comment #4 from Oleg Endo 2012-08-09 21:54:42 UTC --- I'm currently playing around with the macro SHIFT_COUNT_TRUNCATED (sh.h) and the target hook TARGET_SHIFT_TRUNCATION_MASK (which is not implemented yet). Doing the following on rev 190259 (which is actually wrong): sh.h: -#define SHIFT_COUNT_TRUNCATED (! TARGET_SH3 && ! TARGET_SH2A) +#define SHIFT_COUNT_TRUNCATED (1) sh.c: +/* Implement the TARGET_SHIFT_TRUNCATION_MASK target hook. */ + +#undef TARGET_SHIFT_TRUNCATION_MASK +#define TARGET_SHIFT_TRUNCATION_MASK sh_shift_truncation_mask + +static unsigned HOST_WIDE_INT +sh_shift_truncation_mask (enum machine_mode mode) +{ + int bitsize = GET_MODE_BIT_SIZE (mode); + + if (TARGET_SHMEDIA) + return bitsize - 1; + + return MAX (32, bitsize) - 1; +} ... and looking at some CSiBE size results, I see the a couple of weird cases similar to what happens to the set_bh_page function in linux-2.4.23-pre3-testplatform/fs/buffer.c. Without the changes: ... .L592: mov.l .L598,r1 !! mov r9,r3 mov.l @r1,r2 !! r2 = zone_table[0] add #124,r2 mov.l @(36,r2),r1 mov.l @(32,r2),r2 add r10,r1 mov.l r9,@(56,r8) sub r2,r3 mov r3,r2 mov.l .L599,r3 shar r2 shar r2 mul.l r3,r2 mov #12,r3 sts macl,r2 shld r3,r2 add r2,r1 mov.l r1,@(52,r8) With the changes: ... .L592: mov.l @(24,r8),r0 !! mov r8,r3 mov.l .L598,r1 shlr16 r0 !! shlr8 r0 !! shll2 r0 !! mov.l @(r0,r1),r2 !! r2 = zone_table[page->flags >> ZONE_SHIFT] add #124,r2 mov.l @(36,r2),r1 mov.l @(32,r2),r2 add r10,r1 mov.l r8,@(56,r9) sub r2,r3 mov r3,r2 mov.l .L599,r3 shar r2 shar r2 mul.l r3,r2 mov #12,r3 sts macl,r2 shld r3,r2 add r2,r1 mov.l r1,@(52,r9) It seems that without the (wrong) patch, the index in the inline function 'page_zone' is reduced from 'page->flags >> ZONE_SHIFT' to '0', and thus the resulting code is wrong?! I've tried to reproduce this in an isolated test case but couldn't get it to do the same - the generated code seems always correct, with and without the changes. I'm confused... Kaz, do you have any idea what could be going on there?