From patchwork Sun Dec 21 23:40:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 423225 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 BE91214007D for ; Mon, 22 Dec 2014 10:40:43 +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:cc:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=xA/+aYHbVCFlgn+3 h6ZuOdXh0k2tW0TM2JlACsrzYlcsh4kw9qgNwLQmP+qKml2aU0gmryFRyuOJb0nn hUueUHf1ra79W8SQeVElhnWE5gDhuy6DLw5aFit6BpCBy/nVViaG8ErPxuxI+biF mE2l2Rwr6QQVLvF9C+INhfinyUw= 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:cc:date:in-reply-to:references :content-type:mime-version; s=default; bh=xh/d5WlVFjicdyG2GDx/x9 jUZRY=; b=phf7QhDh8stxbpGuyIr0WFPGVd9es2B5s6vHCeqptSSH2GOn791egD Fi+Lv627SEpWYjj/Snhdn3FNQR+baKQDGlTipRV7mJ1WXCOZUELHCsudCJeU/ZZe rZYpIvOT1S8ohgmwQZTwcqHRot5Wnhtf2MnIRKcMPEvUrInd82gl8= Received: (qmail 878 invoked by alias); 21 Dec 2014 23:40:35 -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 867 invoked by uid 89); 21 Dec 2014 23:40:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mailout04.t-online.de Received: from mailout04.t-online.de (HELO mailout04.t-online.de) (194.25.134.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 21 Dec 2014 23:40:33 +0000 Received: from fwd03.aul.t-online.de (fwd03.aul.t-online.de [172.20.27.148]) by mailout04.t-online.de (Postfix) with SMTP id F28A2439EEB; Mon, 22 Dec 2014 00:40:28 +0100 (CET) Received: from [192.168.0.104] (SyE64mZEQhnle25dPmahqJxk5sKuHCNTwRR2vn36BJVRGZGCtbFwFrvY4vFNw55gkk@[84.180.116.254]) by fwd03.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1Y2q6r-259UBM0; Mon, 22 Dec 2014 00:40:25 +0100 Message-ID: <1419205222.8915.78.camel@yam-132-YW-E178-FTW> Subject: Re: [RFC PATCH 8/9] [SH] Add splitter to addsi3_compact From: Oleg Endo To: Kaz Kojima Cc: gcc-patches Date: Mon, 22 Dec 2014 00:40:22 +0100 In-Reply-To: <20141218.100406.265849576.kkojima@rr.iij4u.or.jp> References: <20141218.100406.265849576.kkojima@rr.iij4u.or.jp> Mime-Version: 1.0 X-IsSubscribed: yes On Thu, 2014-12-18 at 10:04 +0900, Kaz Kojima wrote: > This patch is discussed in PR55212 > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c65 > > and is to make LRA's register elimination work well on SH. > The problem is SH has very limited add instructions only and expands > rA := rB + N to (set rA (const_int N)) and (set rA (plus rA rB)) > instead of (set rA (plus rB (const_int N))). It seems that the former > combination isn't good for LRA's register elimination pass. The patch > adds splitter to addsi3_compact insn so that LRA can see the latter > rtl. > > -- > * config/sh/predicates.md (arith_or_int_operand): New predicate. > * config/sh/sh.md (addsi3): Use arith_or_int_operand for operand 2. > Return fail if operands[0] and operands[1] are overlap when > operands[2] is integer constant. > (*addsi3_compact): Make it define_insn_and_split which splits > reg0 := reg1 + constant to reg0 = constant and reg0 := reg0 + reg1. This triggered a warning about suggested parentheses around the && condition in *addsi3_compact. I've committed the attached patch as r218999. Cheers, Oleg gcc/ChangeLog: PR target/55212 * config/sh/sh.md (*addsi3_compact): Add parentheses around && condition. Add comments. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 218997) +++ gcc/config/sh/sh.md (working copy) @@ -2056,14 +2056,20 @@ [(set_attr "type" "arith_media") (set_attr "highpart" "ignore")]) +;; The *addsi3_compact is made an insn_and_split and accepts actually +;; impossible constraints to make LRA's register elimination work well on SH. +;; The problem is that LRA expects something like +;; (set rA (plus rB (const_int N))) +;; to work. We can do that, but we have to split out an additional reg-reg +;; copy before the actual add insn. (define_insn_and_split "*addsi3_compact" [(set (match_operand:SI 0 "arith_reg_dest" "=r,&r") (plus:SI (match_operand:SI 1 "arith_operand" "%0,r") (match_operand:SI 2 "arith_or_int_operand" "rI08,rn")))] "TARGET_SH1 - && (rtx_equal_p (operands[0], operands[1]) - && arith_operand (operands[2], SImode)) - || ! reg_overlap_mentioned_p (operands[0], operands[1])" + && ((rtx_equal_p (operands[0], operands[1]) + && arith_operand (operands[2], SImode)) + || ! reg_overlap_mentioned_p (operands[0], operands[1]))" "@ add %2,%0 #"