From patchwork Thu Sep 12 13:37:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 274557 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 EE50F2C039F for ; Thu, 12 Sep 2013 23:38:05 +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:to:cc:subject:content-type; q=dns; s=default; b=aiYjH8TncbBPl81bxC3WznPSqWzZStO4RmeNOXO+zA7 4ChinRRVQf6AaoDvKvGqeMiZ19N/teRg9BYRNJnwD162xF70ty7hJFQxVqTGdcrq vxRe1EQBJb85Zqjpoj9i59upEo0Gae8fzdmaQiufjVPMlld2wVvb5biu9ECG11aw = 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:to:cc:subject:content-type; s=default; bh=gJErFXdYTzCJeEXKUQKqHQaW0QY=; b=KrGrSaKttG4Pz/Bsb Jl3DHPqV00snoWqpkdGtHA/9qYhXa7jROZp6zy63yCsQccnCLGgYEqWnsytJtcFv RlLB+vB2q4WAg203KCkk6axgSDyc+pZ4mLvWaKqd70BuI8ossaxhMpcdTzTle+6N gHzyuNmxCw87NWBZASnpuVmxU4= Received: (qmail 12072 invoked by alias); 12 Sep 2013 13:37:58 -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 12058 invoked by uid 89); 12 Sep 2013 13:37:57 -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; Thu, 12 Sep 2013 13:37:57 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, 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 DSNKUjHDrvTJpvllUKN/pFck8ivlahTHJvk9@postini.com; Thu, 12 Sep 2013 13:37:56 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 0581D1E8; Thu, 12 Sep 2013 13:37:32 +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 0591C50A1; Thu, 12 Sep 2013 13:36:58 +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; Thu, 12 Sep 2013 15:37:47 +0200 Message-ID: <5231C3AB.3040401@st.com> Date: Thu, 12 Sep 2013 15:37:47 +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 To: "gcc-patches@gcc.gnu.org" Cc: Oleg Endo , Kaz Kojima Subject: [PATCH, SH4] Fix PR58314 (unsatisfied constraints) X-IsSubscribed: yes The attached patch fixes an ice while building the linux kernel. Reduced in the included testcase. The problem is that we are generating a movhi_reg_reg insn that accepts only registers as operands. Spilling a pseudo on the stack results in an invalid memory load/store constraints. The attached patch allows memory for reload. Tested with the testsuite on sh4-linux and sh-superh-gcc. No performance impact on a large number of benchmarks (EEMBC, CSIBe, spec2006, ...) Oleg, since you moved out the r,r constraints from *mohi into movhi_reg_reg, do you agree ? OK for trunk and 4.8 ? Thanks Christian 2013-09-13 Christian Bruel PR target/58314 * config/sh/sh.md (mov_reg_reg): Allow memory for reload. 2013-09-13 Christian Bruel PR target/58314 * gcc.target/sh/pr58314.c: New test. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 202517) +++ gcc/config/sh/sh.md (working copy) @@ -6893,11 +6893,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/pr58314.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr58314.c (revision 0) +++ gcc/testsuite/gcc.target/sh/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); +}