From patchwork Fri Sep 13 08:43:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 274688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75B042C016E for ; Fri, 13 Sep 2013 18:43:13 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=qJ79Io9m1vpW/uvls G7iWBMgjcYiMMoorXjVk/K0KEhxeceEX8ufqWA97G+ph2h/RQBdlroWQiQ4VQ2nQ GWUBgdPlrvZmvDmIbULahlpShoC3MqcscRmkZYVsEQpdpLK2orBn19d/w088lnVc /9sMdCQwAfzzliB3poEf0y2kcg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:cc:subject:references :in-reply-to:content-type; s=default; bh=q6e0ikaMhIVns5BwWpMd9rJ ND1o=; b=oypYTNHfre9wwr7H7NL5Ulhbj2pKYeBEUff140ImnuSvnfTN+AnVy2W vKDd5YCQFmvQqN3e++WWrXgVlFimFyjyVC1BypgWo35zCD/Y9haML0mmWlz6eO70 6B2SfNOQ4cTi7KLSEl5AMMDuL+5zxan0U1LPiCQ7/QlT4Ys+e0to= Received: (qmail 5061 invoked by alias); 13 Sep 2013 08:43:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 5046 invoked by uid 89); 13 Sep 2013 08:43:06 -0000 Received: from eu1sys200aog123.obsmtp.com (HELO eu1sys200aog123.obsmtp.com) (207.126.144.155) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) SMTP; Fri, 13 Sep 2013 08:43:06 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, MISSING_HEADERS, RDNS_NONE autolearn=no version=3.3.2 X-HELO: eu1sys200aog123.obsmtp.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob123.postini.com ([207.126.147.11]) with SMTP ID DSNKUjLQFZTBbf77joAICt6XC++twIfXhenY@postini.com; Fri, 13 Sep 2013 08:43:04 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8DCD4185 for ; Fri, 13 Sep 2013 08:42:44 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas2.st.com [10.75.90.16]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BBEF54826 for ; Fri, 13 Sep 2013 08:42:11 +0000 (GMT) Received: from [164.129.122.166] (164.129.122.166) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.297.1; Fri, 13 Sep 2013 10:43:00 +0200 Message-ID: <5232D014.8050801@st.com> Date: Fri, 13 Sep 2013 10:43:00 +0200 From: Christian Bruel User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 Cc: "gcc-patches@gcc.gnu.org" Subject: [PATCH, committed] SH: Fix PR58314 (unsatisfied constraints) References: <5231C3AB.3040401@st.com> <20130913.080155.487158670.kkojima@rr.iij4u.or.jp> In-Reply-To: <20130913.080155.487158670.kkojima@rr.iij4u.or.jp> X-IsSubscribed: yes For 4.8 and 4.9 2013-09-13 Christian Bruel PR target/58314 * config/sh/sh.md (mov_reg_reg): Allow memory reloads. 2013-09-13 Christian Bruel PR target/58314 * gcc.target/sh/torture/pr58314.c: New test. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 202556) +++ gcc/config/sh/sh.md (working copy) @@ -6878,10 +6878,11 @@ label: ;; If movqi_reg_reg is specified as an alternative of movqi, movqi will be ;; selected to copy QImode regs. If one of them happens to be allocated ;; on the stack, reload will stick to movqi insn and generate wrong -;; displacement addressing because of the generic m alternatives. -;; With the movqi_reg_reg being specified before movqi it will be initially -;; picked to load/store regs. If the regs regs are on the stack reload will -;; try other insns and not stick to movqi_reg_reg. +;; displacement addressing because of the generic m alternatives. +;; With the movqi_reg_reg being specified before movqi it will be initially +;; picked to load/store regs. If the regs regs are on the stack reload +;; try other insns and not stick to movqi_reg_reg, unless there were spilled +;; pseudos in which case 'm' constraints pertain. ;; The same applies to the movhi variants. ;; ;; Notice, that T bit is not allowed as a mov src operand here. This is to @@ -6893,11 +6894,14 @@ label: ;; reloading MAC subregs otherwise. For that probably special patterns ;; would be required. (define_insn "*mov_reg_reg" - [(set (match_operand:QIHI 0 "arith_reg_dest" "=r") - (match_operand:QIHI 1 "register_operand" "r"))] + [(set (match_operand:QIHI 0 "arith_reg_dest" "=r,m,*z") + (match_operand:QIHI 1 "register_operand" "r,*z,m"))] "TARGET_SH1 && !t_reg_operand (operands[1], VOIDmode)" - "mov %1,%0" - [(set_attr "type" "move")]) + "@ + mov %1,%0 + mov. %1,%0 + mov. %1,%0" + [(set_attr "type" "move,store,load")]) ;; FIXME: The non-SH2A and SH2A variants should be combined by adding ;; "enabled" attribute as it is done in other targets. Index: gcc/testsuite/gcc.target/sh/torture/pr58314.c =================================================================== --- gcc/testsuite/gcc.target/sh/torture/pr58314.c (revision 0) +++ gcc/testsuite/gcc.target/sh/torture/pr58314.c (working copy) @@ -0,0 +1,102 @@ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-Os" } */ + +typedef unsigned short __u16; +typedef unsigned int __u32; + +typedef signed short s16; + + +static inline __attribute__((always_inline)) __attribute__((__const__)) __u16 __arch_swab16(__u16 x) +{ + __asm__( + "swap.b %1, %0" + : "=r" (x) + : "r" (x)); + return x; +} + +void u16_add_cpu(__u16 *var) +{ + *var = __arch_swab16(*var); +} + +typedef struct xfs_mount { + int m_attr_magicpct; +} xfs_mount_t; + +typedef struct xfs_da_args { + struct xfs_mount *t_mountp; + int index; +} xfs_da_args_t; + +typedef struct xfs_dabuf { + void *data; +} xfs_dabuf_t; + +typedef struct xfs_attr_leaf_map { + __u16 base; + __u16 size; +} xfs_attr_leaf_map_t; +typedef struct xfs_attr_leaf_hdr { + __u16 count; + xfs_attr_leaf_map_t freemap[3]; +} xfs_attr_leaf_hdr_t; + +typedef struct xfs_attr_leaf_entry { + __u16 nameidx; +} xfs_attr_leaf_entry_t; + +typedef struct xfs_attr_leafblock { + xfs_attr_leaf_hdr_t hdr; + xfs_attr_leaf_entry_t entries[1]; +} xfs_attr_leafblock_t; + +int +xfs_attr_leaf_remove(xfs_attr_leafblock_t *leaf, xfs_da_args_t *args) +{ + xfs_attr_leaf_hdr_t *hdr; + xfs_attr_leaf_map_t *map; + xfs_attr_leaf_entry_t *entry; + int before, after, smallest, entsize; + int tablesize, tmp, i; + xfs_mount_t *mp; + hdr = &leaf->hdr; + mp = args->t_mountp; + + entry = &leaf->entries[args->index]; + + tablesize = __arch_swab16(hdr->count); + + map = &hdr->freemap[0]; + tmp = map->size; + before = after = -1; + smallest = 3 - 1; + entsize = xfs_attr_leaf_entsize(leaf, args->index); + + for (i = 0; i < 2; map++, i++) { + + if (map->base == tablesize) + u16_add_cpu(&map->base); + + if (__arch_swab16(map->base) + __arch_swab16(map->size) == __arch_swab16(entry->nameidx)) + before = i; + else if (map->base == entsize) + after = i; + else if (__arch_swab16(map->size) < tmp) + smallest = i; + } + + if (before >= 0) + { + map = &hdr->freemap[after]; + map->base = entry->nameidx; + + } + + map = &hdr->freemap[smallest]; + + map->base = __arch_swab16(entry->nameidx); + + return(tmp < mp->m_attr_magicpct); +}