From patchwork Sun Jul 29 22:56:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 173938 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 AEFDF2C007F for ; Mon, 30 Jul 2012 08:57:12 +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=1344207433; 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=9cmzVIi/kAMTcQmusn5A zaxeDCg=; b=OOybI2VcxqiMLKIwmOYOXS2qOSJhhvTd7pmB++LQQxJxpfX4u051 9Ok29Viymi+42XZgcvUi6dNKdiNhpaWVg/uzGMTmDaiVbBf/eoX4BrjNFNqyvouD VpY8W/e8OiyXzu/8Tr4cFpf4EBUh/eS+PVw4wuYGBZSlrS9E/L1nNw0= 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=kYd2GY+4iDLY0+eaLwTDbTPqQZCKSOH6YGzRFiFFj4R2XvuHRJoADsMQsTiD6y I2ouk75WmEVRuCSGf9nVfueTLQ9wW6l+8X9UHHHX7lHljbm8dlMSft0ZU4S8yTYP j00DDV/tTvpYdOXFN/7THiO5Zzzj+N9noulMSGyqLVETw=; Received: (qmail 6058 invoked by alias); 29 Jul 2012 22:57:08 -0000 Received: (qmail 6046 invoked by uid 22791); 29 Jul 2012 22:57:07 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, SUBJ_ALL_CAPS, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout01.t-online.de (HELO mailout01.t-online.de) (194.25.134.80) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 29 Jul 2012 22:56:54 +0000 Received: from fwd14.aul.t-online.de (fwd14.aul.t-online.de ) by mailout01.t-online.de with smtp id 1SvcPs-00004r-GP; Mon, 30 Jul 2012 00:56:52 +0200 Received: from [192.168.0.100] (GQ6R2vZU8hW0CtlD2A8x7rNRwOzORe+ZiamdP5c1imE75X6D9pvIySTO7bCV1N6Z1F@[93.218.155.190]) by fwd14.t-online.de with esmtp id 1SvcPr-0VWqgK0; Mon, 30 Jul 2012 00:56:51 +0200 Message-ID: <1343602608.2304.15.camel@yam-132-YW-E178-FTW> Subject: [SH] PR 39423 From: Oleg Endo To: gcc-patches Date: Mon, 30 Jul 2012 00:56:48 +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, The attached patch adds the combine patterns as discussed in the PR. 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. Test cases will follow in a separate patch. Cheers, Oleg ChangeLog PR target/39423 * config/gcc/sh/sh.md (*movsi_index_disp, *movhi_index_disp): New insns. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 189916) +++ gcc/config/sh/sh.md (working copy) @@ -5107,6 +5107,132 @@ "TARGET_SH1" "sett") + +;; Use the combine pass to transform sequences such as +;; mov r5,r0 +;; add #1,r0 +;; shll2 r0 +;; mov.l @(r0,r4),r0 +;; into +;; shll2 r5 +;; add r4,r5 +;; mov.l @(4,r5),r0 +;; +;; See also PR 39423. +;; FIXME: Fold copy pasted patterns somehow. +;; FIXME: Combine never tries this kind of patterns for DImode. +(define_insn_and_split "*movsi_index_disp" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (mem:SI + (plus:SI + (plus:SI (mult:SI (match_operand:SI 1 "arith_reg_operand" "r") + (match_operand:SI 2 "const_int_operand")) + (match_operand:SI 3 "arith_reg_operand" "r")) + (match_operand:SI 4 "const_int_operand"))))] + "TARGET_SH1 && sh_legitimate_index_p (SImode, operands[4], TARGET_SH2A, true) + && exact_log2 (INTVAL (operands[2])) > 0" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 5) (ashift:SI (match_dup 1) (match_dup 2))) + (set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3))) + (set (match_dup 0) (mem:SI (plus:SI (match_dup 6) (match_dup 4))))] +{ + operands[5] = gen_reg_rtx (SImode); + operands[6] = gen_reg_rtx (SImode); + operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2]))); +}) + +(define_insn_and_split "*movhi_index_disp" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (sign_extend:SI + (mem:HI + (plus:SI + (plus:SI (mult:SI (match_operand:SI 1 "arith_reg_operand" "r") + (match_operand:SI 2 "const_int_operand")) + (match_operand:SI 3 "arith_reg_operand" "r")) + (match_operand:SI 4 "const_int_operand")))))] + "TARGET_SH1 && sh_legitimate_index_p (HImode, operands[4], TARGET_SH2A, true) + && exact_log2 (INTVAL (operands[2])) > 0" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 5) (ashift:SI (match_dup 1) (match_dup 2))) + (set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3))) + (set (match_dup 0) + (sign_extend:SI (mem:HI (plus:SI (match_dup 6) (match_dup 4)))))] +{ + operands[5] = gen_reg_rtx (SImode); + operands[6] = gen_reg_rtx (SImode); + operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2]))); +}) + +(define_insn_and_split "*movhi_index_disp" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (zero_extend:SI + (mem:HI + (plus:SI + (plus:SI (mult:SI (match_operand:SI 1 "arith_reg_operand" "r") + (match_operand:SI 2 "const_int_operand")) + (match_operand:SI 3 "arith_reg_operand" "r")) + (match_operand:SI 4 "const_int_operand")))))] + "TARGET_SH1 && sh_legitimate_index_p (HImode, operands[4], TARGET_SH2A, true) + && exact_log2 (INTVAL (operands[2])) > 0" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 5) (ashift:SI (match_dup 1) (match_dup 2))) + (set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3))) + (set (match_dup 7) + (sign_extend:SI (mem:HI (plus:SI (match_dup 6) (match_dup 4))))) + (set (match_dup 0) (zero_extend:SI (match_dup 8)))] +{ + operands[5] = gen_reg_rtx (SImode); + operands[6] = gen_reg_rtx (SImode); + operands[7] = gen_reg_rtx (SImode); + operands[8] = gen_lowpart (HImode, operands[7]); + operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2]))); +}) + +(define_insn_and_split "*movsi_index_disp" + [(set (mem:SI + (plus:SI + (plus:SI (mult:SI (match_operand:SI 1 "arith_reg_operand" "r") + (match_operand:SI 2 "const_int_operand")) + (match_operand:SI 3 "arith_reg_operand" "r")) + (match_operand:SI 4 "const_int_operand"))) + (match_operand:SI 0 "arith_reg_operand" "r"))] + "TARGET_SH1 && sh_legitimate_index_p (SImode, operands[4], TARGET_SH2A, true) + && exact_log2 (INTVAL (operands[2])) > 0" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 5) (ashift:SI (match_dup 1) (match_dup 2))) + (set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3))) + (set (mem:SI (plus:SI (match_dup 6) (match_dup 4))) (match_dup 0))] +{ + operands[5] = gen_reg_rtx (SImode); + operands[6] = gen_reg_rtx (SImode); + operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2]))); +}) + +(define_insn_and_split "*movhi_index_disp" + [(set (mem:HI + (plus:SI + (plus:SI (mult:SI (match_operand:SI 1 "arith_reg_operand" "r") + (match_operand:SI 2 "const_int_operand")) + (match_operand:SI 3 "arith_reg_operand" "r")) + (match_operand:SI 4 "const_int_operand"))) + (match_operand:HI 0 "arith_reg_operand" "r"))] + "TARGET_SH1 && sh_legitimate_index_p (HImode, operands[4], TARGET_SH2A, true) + && exact_log2 (INTVAL (operands[2])) > 0" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 5) (ashift:SI (match_dup 1) (match_dup 2))) + (set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3))) + (set (mem:HI (plus:SI (match_dup 6) (match_dup 4))) (match_dup 0))] +{ + operands[5] = gen_reg_rtx (SImode); + operands[6] = gen_reg_rtx (SImode); + operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2]))); +}) + ;; Define additional pop for SH1 and SH2 so it does not get ;; placed in the delay slot. (define_insn "*movsi_pop"