From patchwork Mon Mar 16 10:12:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 450457 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 D760014009B for ; Mon, 16 Mar 2015 21:13:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xKhkhF2Z; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=IKApMIYuVmGk17txqTGKvp9h+OqMq0PHTEX7RoFgGAq8yL YxkzXfyG2TZbM2Zb//Wd8Sm16a2F9hB5SZtfcp+KHZpC8aOViVR/Oc+WuT1buThC m2puafIXacAHdqWEK+F1mlId+ugSNQMBtbZENGKkNOdknPgZb/j9E4ppxuBRw= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=BxURC00/6xfYGonufQ89tI52z5c=; b=xKhkhF2Z5s2e2K5cSEw2 9LcB9v2GtHE3Cpx38rzIInXlpMIJSTbzmYeVrRpBjmE2tjbLuSatcKUroUq/wmEI 1brqIXR3PlUO1av1nKpwyi4Smt0ugcBX2IQ3kGGGYEFraxRIp/pUeRyU8CEqjKHA EG3xorOs8mSHLHiIanIXsHg= Received: (qmail 11687 invoked by alias); 16 Mar 2015 10:13:04 -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 11658 invoked by uid 89); 16 Mar 2015 10:13:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Mar 2015 10:13:01 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by service87.mimecast.com; Mon, 16 Mar 2015 10:12:58 +0000 Received: from [10.2.207.50] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 16 Mar 2015 10:12:57 +0000 Message-ID: <5506ACA9.4000909@arm.com> Date: Mon, 16 Mar 2015 10:12:57 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches Subject: [PATCH][expmed] Calculate mult-by-const cost properly in mult_by_coeff_cost X-MC-Unique: 115031610125802001 X-IsSubscribed: yes Hi all, Eyeballing the mult_by_coeff_cost function I think it has a typo/bug. It's supposed to return the cost of multiplying by a constant 'coeff'. It calculates that by taking the cost of a MULT rtx by that constant and comparing it to the cost of synthesizing that multiplication, and returning the cheapest. However, in the MULT rtx cost calculations it creates a MULT rtx of two REGs rather than the a REG and the GEN_INT of coeff as I would expect. This patches fixes that in the obvious way. Tested aarch64-none-elf and bootstrapped on x86_64-linux-gnu. I'm guessing this is stage 1 material at this point? Thanks, Kyrill 2015-03-13 Kyrylo Tkachov * expmed.c (mult_by_coeff_cost): Pass CONT_INT rtx to MULT cost calculation rather than fake_reg. commit fa230baf4f35d03cf072904dc048ce4ffcf43148 Author: Kyrylo Tkachov Date: Thu Mar 12 09:47:06 2015 +0000 [expmed] Calculate mult-by-const properly in mult_by_coeff_cost diff --git a/gcc/expmed.c b/gcc/expmed.c index 0034203..fec9501 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -3285,7 +3285,8 @@ mult_by_coeff_cost (HOST_WIDE_INT coeff, machine_mode mode, bool speed) enum mult_variant variant; rtx fake_reg = gen_raw_REG (mode, LAST_VIRTUAL_REGISTER + 1); - max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, fake_reg), speed); + max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, GEN_INT (coeff)), + speed); if (choose_mult_variant (mode, coeff, &algorithm, &variant, max_cost)) return algorithm.cost.cost; else