From patchwork Tue Jan 27 00:02:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 433094 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DF5391401DD for ; Tue, 27 Jan 2015 11:03:13 +1100 (AEDT) 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:subject:from:to:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=qZ+TH4yoONdWySaQ ua316nv6TYxBIiceXusx/q5TEYBcHZuD5jfQIkd8of243cBdkhrYNKcw4yKGPOb1 nMcBmD0zyTDf8kLmpftiHN4BeA8uDqachWnT1LE7/sZlPMgx6qL3BGMHGtPwcVYa qujE9siCnNIEAuDBGp22mgn8a90= 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:subject:from:to:date:in-reply-to:references :content-type:mime-version; s=default; bh=r9qegyufRetucK2tVxxn2c keOEc=; b=lMsmSAklJquyco/iOSAL9wi+RlnP8Ubtcu0T1YugQ+MYF9yyCNdc8a i6Y//L6eJ9w1/fLT4Cgo0DxtJVEyYI96w0qIJH772Xi46o0CcBXgkOsu3sW9VS35 rIs3tuOcezaSDX4m8ib8KRV4cJLMeKQ2XTLH4pweIENS2VEnPnpYs= Received: (qmail 27356 invoked by alias); 27 Jan 2015 00:03:04 -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 27243 invoked by uid 89); 27 Jan 2015 00:02:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailout07.t-online.de Received: from mailout07.t-online.de (HELO mailout07.t-online.de) (194.25.134.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 27 Jan 2015 00:02:57 +0000 Received: from fwd20.aul.t-online.de (fwd20.aul.t-online.de [172.20.26.140]) by mailout07.t-online.de (Postfix) with SMTP id 988932AF572 for ; Tue, 27 Jan 2015 01:02:53 +0100 (CET) Received: from [192.168.0.105] (rX-noiZrYhzMacM+9bn8J4xho+bAtdeWs2usZfvgYhSeNMJf76M0PiP9Hhe0oUTgjT@[84.180.120.77]) by fwd20.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1YFtcL-47qMDo0; Tue, 27 Jan 2015 01:02:53 +0100 Message-ID: <1422316971.2376.95.camel@yam-132-YW-E178-FTW> Subject: Re: [SH] Introduce treg_set_expr From: Oleg Endo To: gcc-patches@gcc.gnu.org Date: Tue, 27 Jan 2015 01:02:51 +0100 In-Reply-To: <1421966761.2376.78.camel@yam-132-YW-E178-FTW> References: <20150117.224013.482322450.kkojima@rr.iij4u.or.jp> <1421583943.2376.19.camel@yam-132-YW-E178-FTW> <1421708391.2376.27.camel@yam-132-YW-E178-FTW> <20150120.200532.63808742.kkojima@rr.iij4u.or.jp> <1421887903.2376.57.camel@yam-132-YW-E178-FTW> <1421966761.2376.78.camel@yam-132-YW-E178-FTW> Mime-Version: 1.0 X-IsSubscribed: yes On Thu, 2015-01-22 at 23:46 +0100, Oleg Endo wrote: > I will install this the patch from > https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01743.html > in 24h if there are no further objections. > The above mentioned patch has been committed as r220081. This is a small follow up patch that fixes two oversights. One is that there's no point in trying to fit a tst insn constant by right shifting it if it already fits into K08 (currently done when optimizing for size). The other oversight was a code path that hasn't been triggered yet in sh_split_treg_set_expr, into which I ran when trying out more stuff with the treg_set_expr facility. Attached patch has been committed as r220144. Cheers, Oleg gcc/ChangeLog: PR target/49263 * config/sh/sh.c (sh_split_treg_set_expr): Invoke emit_insn before remove_insn. * config/sh/sh.md (tstsi_t): Don't try to optimize constant with right shifts if it already fits into K08. gcc/testsuite/ChangeLog: PR target/49263 * gcc.target/sh/pr49263-4.c: New. Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 220133) +++ gcc/config/sh/sh.c (working copy) @@ -14466,6 +14466,8 @@ fprintf (dump_file, "trailing nott insn %d\n", INSN_UID (nott_insn)); } + emit_insn (insnlist.first); + if (nott_insn != NULL && append_nott) { if (dump_file) @@ -14475,8 +14477,6 @@ append_nott = false; } - emit_insn (insnlist.first); - if (append_nott) nott_insn = emit_insn (gen_nott (get_t_reg_rtx ())); Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 220133) +++ gcc/config/sh/sh.md (working copy) @@ -742,9 +742,13 @@ variant instead and load the constant into a reg. For that we'd need to do some analysis. */ - if ((op1val & 0xFFFF) == 0 - && CONST_OK_FOR_K08 (op1val >> 16) && optimize_size) + if (CONST_OK_FOR_K08 (op1val)) { + /* Do nothing. */ + } + else if ((op1val & 0xFFFF) == 0 + && CONST_OK_FOR_K08 (op1val >> 16) && optimize_size) + { /* Use a swap.w insn to do a shift + reg copy (to R0) in one insn. */ op1val = op1val >> 16; rtx r = gen_reg_rtx (SImode); Index: gcc/testsuite/gcc.target/sh/pr49263-4.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr49263-4.c (revision 0) +++ gcc/testsuite/gcc.target/sh/pr49263-4.c (revision 0) @@ -0,0 +1,10 @@ +/* Verify that TST #imm, R0 instruction is generated if the constant + allows it when compiling for -Os. */ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ +/* { dg-final { scan-assembler-not "and" } } */ +/* { dg-final { scan-assembler-not "extu" } } */ +/* { dg-final { scan-assembler-not "exts" } } */ +/* { dg-final { scan-assembler-not "shlr" } } */ + +#include "pr49263.c"