From patchwork Tue Jun 17 07:47:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 360368 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 36EF0140099 for ; Tue, 17 Jun 2014 17:47:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:cc:date:message-id:mime-version:content-type; q=dns; s=default; b=lpkTgSIoPKQH57UHF6Fl+fBCbolFCbsc3eF8lY1ILJXBBSo62m AKNLVY2qEJdBrpmY8YSvMBHYTBjeUxEWmFtj4BPWi7ovwCKiq8dwZ7MtWQETzUZv JWATBNcNoCo2FGITgkuRyyW2XLYeXFVXrt8IaSgq6Zc1Wy++pHU43CRFA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:cc:date:message-id:mime-version:content-type; s= default; bh=ObJFT8JPPupVTzvlHjWpeM8Y0FM=; b=AqSCEuWedoJCBrzYQxhh /JkC8RIWBqmGQAXTi3Y4YOlNMm+pLf7/3t5iDnxFMXjiqqXuVNfLy5EWTYwG//WJ mfGBGPaDvzGUuzHDsAOGDKAk+dV72SI7YIOZdDU7E8aggnjm00WRgfZPNeeEAgG8 SMXlOQZA58o1TEVjjCbD0AI= Received: (qmail 31756 invoked by alias); 17 Jun 2014 07:47:38 -0000 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 Received: (qmail 31649 invoked by uid 89); 17 Jun 2014 07:47:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 17 Jun 2014 07:47:34 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BC7C6ACC1; Tue, 17 Jun 2014 07:47:31 +0000 (UTC) From: Andreas Schwab To: gcc-patches@gcc.gnu.org Subject: [PATCH] PR54555: Use strict_low_part for loading a constant only if it is cheaper CC: Kazu Hirata X-Yow: Is it 1974? What's for SUPPER? Can I spend my COLLEGE FUND in one wild afternoon?? Date: Tue, 17 Jun 2014 09:47:31 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Postreload may transform (set (REGX) (CONST_INT A)) ... (set (REGX) (CONST_INT B)) to (set (REGX) (CONST_INT A)) ... (set (STRICT_LOW_PART (REGX)) (CONST_INT B)), but it should do that only if the latter is cheaper. On m68k, a full word load of a small constant with moveq is cheaper than doing a byte load with move.b. Tested on m68k-suse-linux and x86_64-suse-linux. In both cases the size of cc1* becomes smaller with this change. Andreas. PR rtl-optimization/54555 * postreload.c (move2add_use_add2_insn): Only substitute STRICT_LOW_PART if it is cheaper. --- gcc/postreload.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/postreload.c b/gcc/postreload.c index 9d71649..89f0c84 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -1805,10 +1805,14 @@ move2add_use_add2_insn (rtx reg, rtx sym, rtx off, rtx insn) gen_rtx_STRICT_LOW_PART (VOIDmode, narrow_reg), narrow_src); - changed = validate_change (insn, &PATTERN (insn), - new_set, 0); - if (changed) - break; + get_full_set_rtx_cost (new_set, &newcst); + if (costs_lt_p (&newcst, &oldcst, speed)) + { + changed = validate_change (insn, &PATTERN (insn), + new_set, 0); + if (changed) + break; + } } } }