From patchwork Mon May 7 20:40:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 157449 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 05110B6FA9 for ; Tue, 8 May 2012 06:41:06 +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=1337028068; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=WUoZADj269rmN24QDEsJL6hHIos=; b=p8AHhdiVewzP4X4by+5Mhd2b3JkxmrmF9HVUjo1h+VN0i//cYEO9yYDVySllSB 4PIL5PGnekgbTUp76t+nyxJdE0U76eSOkDPLhwXX92nbcWPeRrWYXPX3rTC8ypfB ICmxYFMYGz9RYVFsJSMcVOspwYpQOQwE40hWmJpoWdGQw= 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:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=L/q5uYmpiDmdOQFLUFe5CY9jgpgHRIghEaQMoOhoP/VbIysqXkV8UjFx9qgH2j VUeKjT1k/5s1Dk4ZVPsugUXktJFjiyFB27Qs9vVUkHPYbvA1XRr7Jt3ldOa+NuE0 tNBgaak411L2FKb2FJJ/yQBB/wdW69hwI9QHsOjlIDYiE=; Received: (qmail 28505 invoked by alias); 7 May 2012 20:40:58 -0000 Received: (qmail 28493 invoked by uid 22791); 7 May 2012 20:40:57 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 May 2012 20:40:43 +0000 Received: by yhjj56 with SMTP id j56so5235473yhj.20 for ; Mon, 07 May 2012 13:40:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.182.73 with SMTP id n49mr21319773yhm.100.1336423243059; Mon, 07 May 2012 13:40:43 -0700 (PDT) Received: by 10.146.124.5 with HTTP; Mon, 7 May 2012 13:40:42 -0700 (PDT) In-Reply-To: References: Date: Mon, 7 May 2012 22:40:42 +0200 Message-ID: Subject: Re: [RFC PATCH, i386]: Implement ix86_set_reg_reg_cost, fix PR 53250 "Splitting reg" failure. From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford 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 On Mon, May 7, 2012 at 10:35 PM, Uros Bizjak wrote: Now with a patch and ChangeLog: 2012-05-07 Uros Bizjak PR target/53250 * config/i386/i386.c (ix86_set_reg_reg_cost): New function. (ix86_rtx_costs): Handle SET. > Patch was tested on x86_64-pc-linux-gnu {,-m32}. > > I have also #define LOG_COST 1 temporarily and looked at generated > cost calculations for various -msse* settings. > > I will wait for a day for possible comments on the implementation > before the patch will be committed to mainline SVN. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 187259) +++ config/i386/i386.c (working copy) @@ -31861,6 +31861,52 @@ ix86_modes_tieable_p (enum machine_mode mode1, enu return false; } +/* Return the cost of moving between two registers of mode MODE. */ + +static int +ix86_set_reg_reg_cost (enum machine_mode mode) +{ + unsigned int units = UNITS_PER_WORD; + + switch (GET_MODE_CLASS (mode)) + { + default: + break; + + case MODE_CC: + units = GET_MODE_SIZE (CCmode); + break; + + case MODE_FLOAT: + if ((TARGET_SSE2 && mode == TFmode) + || (TARGET_80387 && mode == XFmode) + || ((TARGET_80387 || TARGET_SSE2) && mode == DFmode) + || ((TARGET_80387 || TARGET_SSE) && mode == SFmode)) + units = GET_MODE_SIZE (mode); + break; + + case MODE_COMPLEX_FLOAT: + if ((TARGET_SSE2 && mode == TCmode) + || (TARGET_80387 && mode == XCmode) + || ((TARGET_80387 || TARGET_SSE2) && mode == DCmode) + || ((TARGET_80387 || TARGET_SSE) && mode == SCmode)) + units = GET_MODE_SIZE (mode); + break; + + case MODE_VECTOR_INT: + case MODE_VECTOR_FLOAT: + if ((TARGET_AVX && VALID_AVX256_REG_MODE (mode)) + || (TARGET_SSE2 && VALID_SSE2_REG_MODE (mode)) + || (TARGET_SSE && VALID_SSE_REG_MODE (mode)) + || (TARGET_MMX && VALID_MMX_REG_MODE (mode))) + units = GET_MODE_SIZE (mode); + } + + /* Return the cost of moving between two registers of mode MODE, + assuming that the move will be in pieces of at most UNITS bytes. */ + return COSTS_N_INSNS ((GET_MODE_SIZE (mode) + units - 1) / units); +} + /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. */ @@ -31875,6 +31921,15 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, switch (code) { + case SET: + if (register_operand (SET_DEST (x), VOIDmode) + && reg_or_0_operand (SET_SRC (x), VOIDmode)) + { + *total = ix86_set_reg_reg_cost (GET_MODE (SET_DEST (x))); + return true; + } + return false; + case CONST_INT: case CONST: case LABEL_REF: