From patchwork Tue Oct 30 09:24:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 195344 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 1E6832C00A8 for ; Tue, 30 Oct 2012 20:25:24 +1100 (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=1352193925; 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=wivaeh6b9R4T9r2oTIoS 10C4onk=; b=VwP6qAcJrgvkMuqfXU3DZtVE3kCwPs8hXDT40WtpdUaLlK9rokyo 4tZzkw2GXj0i1q+hyjphAaKt/Fj0iAu53zxNXfqUzRRHZ6WOy2dLRnsfOx2QAbpY 41n2uddsEt1X+q2jrfkKS8PzatD8xecJVSO107MYYdqXH1KRIJNq0/Q= 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=b0IDOFa/uVbkrWdRkQiCFtMEHYhgv8gOHmflJSgc+cbvIWP+UyRf1E1+fAebeM /8kFAtrNr0Zzx0wz65nQAK0g4mK15Gpp8eKuM5VrEEOt79ITTdgQakrgJrM7VJE8 s/TzoSwHoe+ka4gh4IJvuFKOYmn86x2OrLmwoJLx2ay4Y=; Received: (qmail 19547 invoked by alias); 30 Oct 2012 09:25:14 -0000 Received: (qmail 19526 invoked by uid 22791); 30 Oct 2012 09:25:13 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout10.t-online.de (HELO mailout10.t-online.de) (194.25.134.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Oct 2012 09:25:07 +0000 Received: from fwd16.aul.t-online.de (fwd16.aul.t-online.de ) by mailout10.t-online.de with smtp id 1TT84F-0002xZ-Ak; Tue, 30 Oct 2012 10:25:03 +0100 Received: from [192.168.0.100] (Tl+TGMZCZhrvRmdU6zACWENMui+suMgnZtnwvTuxNmRU7M8CjVw70slPflXHi-vgOm@[87.157.45.111]) by fwd16.t-online.de with esmtp id 1TT84B-082oiW0; Tue, 30 Oct 2012 10:24:59 +0100 Message-ID: <1351589095.25600.23.camel@yam-132-YW-E178-FTW> Subject: [SH, committed] PR 54963 From: Oleg Endo To: gcc-patches Date: Tue, 30 Oct 2012 10:24:55 +0100 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 is the latest proposed patch from the PR. Tested on rev 192482 with make -k check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" and no new failures. Pre-approved by Kaz in the PR. Committed as rev 192983. Cheers, Oleg gcc/ChangeLog: PR target/54963 * config/sh/iterators.md (SIDI): New mode iterator. * config/sh/sh.md (negdi2): Use parallel around operation and T_REG clobber in expander. (*negdi2): Mark output operand as early clobbered. Add T_REG clobber. Split after reload. Simplify split code. (abssi2, absdi2): Fold expanders into abs2. (*abssi2, *absdi2): Fold into *abs2 insn_and_split. Split insns before reload. (*negabssi2, *negabsdi2): Fold into *negabs2. Add T_REG clobber. Split insns before reload. (negsi_cond): Reformat. Use emit_move_insn instead of gen_movesi. (negdi_cond): Reformat. Use emit_move_insn instead of a pair of gen_movsi. Split insn before reload. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 192482) +++ gcc/config/sh/sh.md (working copy) @@ -5177,28 +5177,25 @@ ;; Don't expand immediately because otherwise neg:DI (abs:DI) will not be ;; combined. (define_expand "negdi2" - [(set (match_operand:DI 0 "arith_reg_dest" "") - (neg:DI (match_operand:DI 1 "arith_reg_operand" ""))) - (clobber (reg:SI T_REG))] - "TARGET_SH1" - "") + [(parallel [(set (match_operand:DI 0 "arith_reg_dest") + (neg:DI (match_operand:DI 1 "arith_reg_operand"))) + (clobber (reg:SI T_REG))])] + "TARGET_SH1") (define_insn_and_split "*negdi2" - [(set (match_operand:DI 0 "arith_reg_dest" "=r") - (neg:DI (match_operand:DI 1 "arith_reg_operand" "r")))] + [(set (match_operand:DI 0 "arith_reg_dest" "=&r") + (neg:DI (match_operand:DI 1 "arith_reg_operand" "r"))) + (clobber (reg:SI T_REG))] "TARGET_SH1" "#" - "TARGET_SH1" + "&& reload_completed" [(const_int 0)] { - rtx low_src = gen_lowpart (SImode, operands[1]); - rtx high_src = gen_highpart (SImode, operands[1]); - rtx low_dst = gen_lowpart (SImode, operands[0]); - rtx high_dst = gen_highpart (SImode, operands[0]); - emit_insn (gen_clrt ()); - emit_insn (gen_negc (low_dst, low_src)); - emit_insn (gen_negc (high_dst, high_src)); + emit_insn (gen_negc (gen_lowpart (SImode, operands[0]), + gen_lowpart (SImode, operands[1]))); + emit_insn (gen_negc (gen_highpart (SImode, operands[0]), + gen_highpart (SImode, operands[1]))); DONE; }) @@ -5272,38 +5269,53 @@ (const_int -1)))] "TARGET_SHMEDIA" "") -(define_expand "abssi2" - [(set (match_operand:SI 0 "arith_reg_dest" "") - (abs:SI (match_operand:SI 1 "arith_reg_operand" ""))) +(define_expand "abs2" + [(parallel [(set (match_operand:SIDI 0 "arith_reg_dest") + (abs:SIDI (match_operand:SIDI 1 "arith_reg_operand"))) + (clobber (reg:SI T_REG))])] + "TARGET_SH1") + +(define_insn_and_split "*abs2" + [(set (match_operand:SIDI 0 "arith_reg_dest") + (abs:SIDI (match_operand:SIDI 1 "arith_reg_operand"))) (clobber (reg:SI T_REG))] "TARGET_SH1" - "") - -(define_insn_and_split "*abssi2" - [(set (match_operand:SI 0 "arith_reg_dest" "=r") - (abs:SI (match_operand:SI 1 "arith_reg_operand" "r")))] - "TARGET_SH1" "#" - "TARGET_SH1" + "&& can_create_pseudo_p ()" [(const_int 0)] { - emit_insn (gen_cmpgesi_t (operands[1], const0_rtx)); - emit_insn (gen_negsi_cond (operands[0], operands[1], operands[1], - const1_rtx)); + if (mode == SImode) + emit_insn (gen_cmpgesi_t (operands[1], const0_rtx)); + else + { + rtx high_src = gen_highpart (SImode, operands[1]); + emit_insn (gen_cmpgesi_t (high_src, const0_rtx)); + } + + emit_insn (gen_neg_cond (operands[0], operands[1], operands[1], + const1_rtx)); DONE; }) -(define_insn_and_split "*negabssi2" - [(set (match_operand:SI 0 "arith_reg_dest" "=r") - (neg:SI (abs:SI (match_operand:SI 1 "arith_reg_operand" "r"))))] +(define_insn_and_split "*negabs2" + [(set (match_operand:SIDI 0 "arith_reg_dest") + (neg:SIDI (abs:SIDI (match_operand:SIDI 1 "arith_reg_operand")))) + (clobber (reg:SI T_REG))] "TARGET_SH1" "#" - "TARGET_SH1" + "&& can_create_pseudo_p ()" [(const_int 0)] { - emit_insn (gen_cmpgesi_t (operands[1], const0_rtx)); - emit_insn (gen_negsi_cond (operands[0], operands[1], operands[1], - const0_rtx)); + if (mode == SImode) + emit_insn (gen_cmpgesi_t (operands[1], const0_rtx)); + else + { + rtx high_src = gen_highpart (SImode, operands[1]); + emit_insn (gen_cmpgesi_t (high_src, const0_rtx)); + } + + emit_insn (gen_neg_cond (operands[0], operands[1], operands[1], + const0_rtx)); DONE; }) @@ -5316,10 +5328,10 @@ (define_insn_and_split "negsi_cond" [(set (match_operand:SI 0 "arith_reg_dest" "=r,r") - (if_then_else:SI (eq:SI (reg:SI T_REG) - (match_operand:SI 3 "const_int_operand" "M,N")) - (match_operand:SI 1 "arith_reg_operand" "0,0") - (neg:SI (match_operand:SI 2 "arith_reg_operand" "r,r"))))] + (if_then_else + (eq:SI (reg:SI T_REG) (match_operand:SI 3 "const_int_operand" "M,N")) + (match_operand:SI 1 "arith_reg_operand" "0,0") + (neg:SI (match_operand:SI 2 "arith_reg_operand" "r,r"))))] "TARGET_SH1 && TARGET_ZDCBRANCH" { static const char* alt[] = @@ -5339,7 +5351,7 @@ { rtx skip_neg_label = gen_label_rtx (); - emit_insn (gen_movsi (operands[0], operands[1])); + emit_move_insn (operands[0], operands[1]); emit_jump_insn (INTVAL (operands[3]) ? gen_branch_true (skip_neg_label) @@ -5352,63 +5364,21 @@ [(set_attr "type" "arith") ;; poor approximation (set_attr "length" "4")]) -(define_expand "absdi2" - [(set (match_operand:DI 0 "arith_reg_dest" "") - (abs:DI (match_operand:DI 1 "arith_reg_operand" ""))) +(define_insn_and_split "negdi_cond" + [(set (match_operand:DI 0 "arith_reg_dest") + (if_then_else + (eq:SI (reg:SI T_REG) (match_operand:SI 3 "const_int_operand")) + (match_operand:DI 1 "arith_reg_operand") + (neg:DI (match_operand:DI 2 "arith_reg_operand")))) (clobber (reg:SI T_REG))] "TARGET_SH1" - "") - -(define_insn_and_split "*absdi2" - [(set (match_operand:DI 0 "arith_reg_dest" "=r") - (abs:DI (match_operand:DI 1 "arith_reg_operand" "r")))] - "TARGET_SH1" "#" - "&& reload_completed" + "&& can_create_pseudo_p ()" [(const_int 0)] { - rtx high_src = gen_highpart (SImode, operands[1]); - emit_insn (gen_cmpgesi_t (high_src, const0_rtx)); - emit_insn (gen_negdi_cond (operands[0], operands[1], operands[1], - const1_rtx)); - DONE; -}) - -(define_insn_and_split "*negabsdi2" - [(set (match_operand:DI 0 "arith_reg_dest" "=r") - (neg:DI (abs:DI (match_operand:DI 1 "arith_reg_operand" "r"))))] - "TARGET_SH1" - "#" - "&& reload_completed" - [(const_int 0)] -{ - rtx high_src = gen_highpart (SImode, operands[1]); - emit_insn (gen_cmpgesi_t (high_src, const0_rtx)); - emit_insn (gen_negdi_cond (operands[0], operands[1], operands[1], - const0_rtx)); - DONE; -}) - -(define_insn_and_split "negdi_cond" - [(set (match_operand:DI 0 "arith_reg_dest" "=r,r") - (if_then_else:DI (eq:SI (reg:SI T_REG) - (match_operand:SI 3 "const_int_operand" "M,N")) - (match_operand:DI 1 "arith_reg_operand" "r,r") - (neg:DI (match_operand:DI 2 "arith_reg_operand" "1,1"))))] - "TARGET_SH1" - "#" - "TARGET_SH1" - [(const_int 0)] -{ - rtx low_src = gen_lowpart (SImode, operands[1]); - rtx high_src = gen_highpart (SImode, operands[1]); - rtx low_dst = gen_lowpart (SImode, operands[0]); - rtx high_dst = gen_highpart (SImode, operands[0]); - rtx skip_neg_label = gen_label_rtx (); - emit_insn (gen_movsi (low_dst, low_src)); - emit_insn (gen_movsi (high_dst, high_src)); + emit_move_insn (operands[0], operands[1]); emit_jump_insn (INTVAL (operands[3]) ? gen_branch_true (skip_neg_label) @@ -5417,8 +5387,11 @@ if (!INTVAL (operands[3])) emit_insn (gen_clrt ()); - emit_insn (gen_negc (low_dst, low_src)); - emit_label_after (skip_neg_label, emit_insn (gen_negc (high_dst, high_src))); + emit_insn (gen_negc (gen_lowpart (SImode, operands[0]), + gen_lowpart (SImode, operands[1]))); + emit_label_after (skip_neg_label, + emit_insn (gen_negc (gen_highpart (SImode, operands[0]), + gen_highpart (SImode, operands[1])))); DONE; }) Index: gcc/config/sh/iterators.md =================================================================== --- gcc/config/sh/iterators.md (revision 192482) +++ gcc/config/sh/iterators.md (working copy) @@ -22,6 +22,7 @@ (define_mode_iterator QIHISI [QI HI SI]) (define_mode_iterator QIHI [QI HI]) (define_mode_iterator HISI [HI SI]) +(define_mode_iterator SIDI [SI DI]) ;; Mode attributes that can be used as the instruction suffix for mode ;; variant instructions.