From patchwork Wed Sep 21 23:46:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 115871 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 5C12DB6F80 for ; Thu, 22 Sep 2011 09:47:33 +1000 (EST) Received: (qmail 28314 invoked by alias); 21 Sep 2011 23:47:31 -0000 Received: (qmail 28305 invoked by uid 22791); 21 Sep 2011 23:47:30 -0000 X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL, BAYES_50, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, TW_XF, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout02.t-online.de (HELO mailout02.t-online.de) (194.25.134.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Sep 2011 23:47:15 +0000 Received: from fwd10.aul.t-online.de (fwd10.aul.t-online.de ) by mailout02.t-online.de with smtp id 1R6WVV-00057G-6L; Thu, 22 Sep 2011 01:47:13 +0200 Received: from [192.168.0.104] (rX1N0MZ-QhSgW-c0GapJv4AXtWm6pTNcUdtKuIvybwaEKkXL1Mq3eUYQB5ZtTvcQR6@[93.218.163.100]) by fwd10.t-online.de with esmtp id 1R6WVM-0n0HNQ0; Thu, 22 Sep 2011 01:47:04 +0200 Subject: Re: [SH] AND/OR/XOR costs calculation From: Oleg Endo To: Kaz Kojima Cc: gcc-patches@gcc.gnu.org In-Reply-To: <20110921.123045.388362162.kkojima@rr.iij4u.or.jp> References: <1316567224.1874.138.camel@yam-132-YW-E178-FTW> <20110921.123045.388362162.kkojima@rr.iij4u.or.jp> Date: Thu, 22 Sep 2011 01:46:47 +0200 Message-ID: <1316648807.1874.220.camel@yam-132-YW-E178-FTW> 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 > A few minor nits: Thanks for the hints. The attached patch and changelog below should do now. > BTW, have you done your paper work with FSF? > Yep. Took a while but it's done now. Cheers, Oleg 2011-09-21 Oleg Endo * config/sh/sh.c (andcosts): Renamed to and_xor_ior_costs. Added AND special case. Adapted comments. (sh_rtx_costs): Added XOR and IOR case. Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 178946) +++ gcc/config/sh/sh.c (working copy) @@ -242,7 +242,7 @@ static int flow_dependent_p (rtx, rtx); static void flow_dependent_p_1 (rtx, const_rtx, void *); static int shiftcosts (rtx); -static int andcosts (rtx); +static int and_xor_ior_costs (rtx, int code); static int addsubcosts (rtx); static int multcosts (rtx); static bool unspec_caller_rtx_p (rtx); @@ -2830,14 +2830,15 @@ return shift_insns[value]; } -/* Return the cost of an AND operation. */ +/* Return the cost of an AND/XOR/IOR operation. */ static inline int -andcosts (rtx x) +and_xor_ior_costs (rtx x, int code) { int i; - /* Anding with a register is a single cycle and instruction. */ + /* A logical operation with two registers is a single cycle + instruction. */ if (!CONST_INT_P (XEXP (x, 1))) return 1; @@ -2853,17 +2854,18 @@ } /* These constants are single cycle extu.[bw] instructions. */ - if (i == 0xff || i == 0xffff) + if ((i == 0xff || i == 0xffff) && code == AND) return 1; - /* Constants that can be used in an and immediate instruction in a single - cycle, but this requires r0, so make it a little more expensive. */ + /* Constants that can be used in an instruction as an immediate are + a single cycle, but this requires r0, so make it a little more + expensive. */ if (CONST_OK_FOR_K08 (i)) return 2; - /* Constants that can be loaded with a mov immediate and an and. + /* Constants that can be loaded with a mov immediate need one more cycle. This case is probably unnecessary. */ if (CONST_OK_FOR_I08 (i)) return 2; - /* Any other constants requires a 2 cycle pc-relative load plus an and. + /* Any other constant requires an additional 2 cycle pc-relative load. This case is probably unnecessary. */ return 3; } @@ -3032,7 +3034,9 @@ return true; case AND: - *total = COSTS_N_INSNS (andcosts (x)); + case XOR: + case IOR: + *total = COSTS_N_INSNS (and_xor_ior_costs (x, code)); return true; case MULT: