From patchwork Sun Jul 29 22:44:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 173936 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]) by ozlabs.org (Postfix) with SMTP id 7C95A2C008D for ; Mon, 30 Jul 2012 08:44:49 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344206690; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Subject:From:To:Date:Content-Type:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=ZqtS7fvoE8Qd5oxc4xcr 5gL35q8=; b=w39hR76T8InB2uRc5D5uYnSEdblKw/j8w1ApRZj0f0m6AeTYE3y4 rzxKvQFDXObCF/IrVe4d//PhczZJ77pp0yuAVKgw0fJKBuu5sOu4J0buCFE9BL5K R7YoAmaOvD7N8bIw6Yfw8rAYh4J4YCvSIALKE8JEJMqUHKtCbX2qwJo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Subject:From:To:Date:Content-Type:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=GjiqrUW34+tLwuXiqsiYE2bKpe5VJkawDCfFEL9Afddhy3e9UyWXkAn56EgD/V Y+govuhlXEyFpGIMfCzQOFF7r/WYGhlKin8gw6J6CbiiKRDuHFihgOYoEm6OJz9q ClfPeovu/7XPqtWnip4AXwoaWp79XIO/hUxcXrpmsdaaE=; Received: (qmail 2837 invoked by alias); 29 Jul 2012 22:44:45 -0000 Received: (qmail 2828 invoked by uid 22791); 29 Jul 2012 22:44:44 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, TW_VR, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout06.t-online.de (HELO mailout06.t-online.de) (194.25.134.19) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 29 Jul 2012 22:44:29 +0000 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de ) by mailout06.t-online.de with smtp id 1SvcDq-0008OV-D5; Mon, 30 Jul 2012 00:44:26 +0200 Received: from [192.168.0.100] (SUBwiyZDYhqGctJIAABr6F9wiHI-+GQ5Qx9LCCS4lmngE0CstNgPos-b+OoQjp3wBA@[93.218.155.190]) by fwd22.t-online.de with esmtp id 1SvcDq-2DNZuC0; Mon, 30 Jul 2012 00:44:26 +0200 Message-ID: <1343601863.2304.4.camel@yam-132-YW-E178-FTW> Subject: [SH] PR 51244 - Improve T bit to reg store From: Oleg Endo To: gcc-patches Date: Mon, 30 Jul 2012 00:44:23 +0200 Mime-Version: 1.0 X-IsSubscribed: yes 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 Hello, This improves some cases where the T bit is stored as all ones or all zeros to a GP reg. Tested on rev 189916 with make -k check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb, -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" and no new failures. OK? Cheers, Oleg ChangeLog: PR target/51244 * config/sh/sh.md (mov_neg_si_t): Move to Scc instructions section. Use t_reg_operand predicate. Add split for negated case. (ashrsi2_31): Pass get_t_reg_rtx to gen_mov_neg_si_t. * config/sh/sh.c (expand_ashiftrt): Likewise. testsuite/ChangeLog: PR target/51244 * gcc.target/sh/pr51244-4.c: New. Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 189917) +++ gcc/config/sh/sh.c (working copy) @@ -3481,7 +3481,7 @@ { emit_insn (gen_cmpgtsi_t (force_reg (SImode, CONST0_RTX (SImode)), operands[1])); - emit_insn (gen_mov_neg_si_t (operands[0])); + emit_insn (gen_mov_neg_si_t (operands[0], get_t_reg_rtx ())); return true; } emit_insn (gen_ashrsi2_31 (operands[0], operands[1])); Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 189916) +++ gcc/config/sh/sh.md (working copy) @@ -1584,15 +1584,6 @@ "subc %2,%0" [(set_attr "type" "arith")]) -;; life_analysis thinks rn is live before subc rn,rn, so make a special -;; pattern for this case. This helps multimedia applications that compute -;; the sum of absolute differences. -(define_insn "mov_neg_si_t" - [(set (match_operand:SI 0 "arith_reg_dest" "=r") (neg:SI (reg:SI T_REG)))] - "TARGET_SH1" - "subc %0,%0" - [(set_attr "type" "arith")]) - (define_insn "*subsi3_internal" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (minus:SI (match_operand:SI 1 "arith_reg_operand" "0") @@ -3797,7 +3788,7 @@ [(const_int 0)] { emit_insn (gen_ashlsi_c (operands[0], operands[1])); - emit_insn (gen_mov_neg_si_t (copy_rtx (operands[0]))); + emit_insn (gen_mov_neg_si_t (operands[0], get_t_reg_rtx ())); DONE; }) @@ -9704,6 +9695,25 @@ "" [(const_int 0)]) +;; Store T bit as all zeros or ones in a reg. +(define_insn "mov_neg_si_t" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (neg:SI (match_operand 1 "t_reg_operand" "")))] + "TARGET_SH1" + "subc %0,%0" + [(set_attr "type" "arith")]) + +;; Store negated T bit as all zeros or ones in a reg. +;; Use the following sequence: +;; subc Rn,Rn ! Rn = Rn - Rn - T; T = T +;; not Rn,Rn ! Rn = 0 - Rn +(define_split + [(set (match_operand:SI 0 "arith_reg_dest" "") + (neg:SI (match_operand 1 "negt_reg_operand" "")))] + "TARGET_SH1" + [(set (match_dup 0) (neg:SI (reg:SI T_REG))) + (set (match_dup 0) (not:SI (match_dup 0)))]) + ;; The *movtt pattern eliminates redundant T bit to T bit moves / tests. (define_insn_and_split "*movtt" [(set (reg:SI T_REG) Index: gcc/testsuite/gcc.target/sh/pr51244-4.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr51244-4.c (revision 0) +++ gcc/testsuite/gcc.target/sh/pr51244-4.c (revision 0) @@ -0,0 +1,19 @@ +/* Check that storing the (negated) T bit as all ones or zeros in a reg + uses the subc instruction. On SH2A a sequence with the movrt instruction + is also OK instead of subc. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O1 -mbranch-cost=2" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */ +/* { dg-final { scan-assembler-not "movt|tst|negc" } } */ +/* { dg-final { scan-assembler "subc|movrt|neg|not" } } */ + +int test_00 (int x, int y) +{ + return x != y ? -1 : 0; +} + +int test_01 (int x, int y) +{ + return x == y ? -1 : 0; +} +