From patchwork Fri Jan 22 09:52:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 571595 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 6DBFB14031D for ; Fri, 22 Jan 2016 20:53:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CbrmNRps; 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:cc:subject:content-type; q=dns; s=default; b=ZmhWhbRtXx7aG81sM64/TGDZ0J5XqxNnmFEHuoCQvEc nnAppx1m8krtR8zTY7W7n6shWSKxFWAFNX+mKOwBfi9Oqu0n0eRfOf06sJQUUj2h AZ5DAI+Slb6oP560ROABNG+vxNrEwPY9mkq4C/O7ga3GAyC3udYGPqT9rF8mH5oE = 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:cc:subject:content-type; s=default; bh=vU801YtNS9kkM4rp4mGyCwWSp5U=; b=CbrmNRps6OW/Uw5eo 1J5tW1iYrJsYJrusBVUVucMIJdTxMablgmTKc7q7Y5KvhuwoNnjNUjnqw0kJJoLt QnXqOAQOEJ1bXJg6/+9vWqyRGsciVN0+2AGv/HcpK4ulQlkeidzhd1a2wOIV+0TA OjWWhM07Ykj4+i/3DK2KPUNiNY= Received: (qmail 52281 invoked by alias); 22 Jan 2016 09:52: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 51967 invoked by uid 89); 22 Jan 2016 09:52:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-languages-length:1483, 103218, rtx_code X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Jan 2016 09:52:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5AB8649; Fri, 22 Jan 2016 01:51:54 -0800 (PST) Received: from [10.2.206.200] (e100706-lin.cambridge.arm.com [10.2.206.200]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C15BC3F529; Fri, 22 Jan 2016 01:52:32 -0800 (PST) Message-ID: <56A1FBDF.6020402@foss.arm.com> Date: Fri, 22 Jan 2016 09:52:31 +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 CC: Ramana Radhakrishnan , Richard Earnshaw , Jim Wilson Subject: [PATCH][ARM][2/4] Fix operand costing logic for SMUL[TB][TB] Hi all, As part of investigating the codegen effects of a fix for PR 65932 I found we assign too high a cost for the sign-extending multiply instruction SMULBB. This is because we add the cost of a multiply-extend but then also recurse into the SIGN_EXTEND sub-expressions rather than the registers (or subregs) being sign-extended. This patch is a simple fix. The fix is right by itself, but in combination with patch 3 fix the gcc.target/arm/wmul-2.c testcase. Bootstrapped and tested on arm-none-linux-gnueabihf. Ok for trunk? Thanks, Kyrill 2016-01-22 Kyrylo Tkachov * config/arm/arm.c (arm_new_rtx_costs, MULT case): Properly extract the operands of the SIGN_EXTENDs from a SMUL[TB][TB] rtx. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 17f00b5a1de21de35366b82040a7ad46d65f899e..ee3ebe4561ea3d9791fabdfcec8b16af63bd4d20 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -10321,8 +10321,10 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, /* SMUL[TB][TB]. */ if (speed_p) *cost += extra_cost->mult[0].extend; - *cost += rtx_cost (XEXP (x, 0), mode, SIGN_EXTEND, 0, speed_p); - *cost += rtx_cost (XEXP (x, 1), mode, SIGN_EXTEND, 1, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 0), 0), mode, + SIGN_EXTEND, 0, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 1), 0), mode, + SIGN_EXTEND, 1, speed_p); return true; } if (speed_p)