From patchwork Thu Dec 14 19:12:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 848749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-469247-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xjI03/zB"; dkim-atps=neutral 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 3yyNVs4TVpz9t39 for ; Fri, 15 Dec 2017 06:12:52 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=kLNY2 B25YdOhNYhSrGs15RFW9IwMHXax+vUWaJnTfK2uVxtMqVkmnw7/MxL2ULqvyEiEB I8dGEUips82f46Zv9QkyXrWO5TymrmuxiDnSqA6YlXjyJKq5FlhQSoqebP6juDlw EkJeyllxla4fMkyl6C/Y2JMsiH2qhS7HrDjMAs= 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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=lYWw+tB8hpD KzMsf5rG0wxWazCs=; b=xjI03/zBsPx/wnde+wqUCwqEIWrHH3ObOG/DxhVq8YS 58TrkcnJluH//svjdsa9x5DTVHb4l3343EuSP/WbMSK/XNvCav+S1pIxyXpg7947 RRSVPq4CrRqldsoP6u4iqffJXn5XX1ouPYe67Bp32NKuENxv2GV+oJ2clGudCqvk = Received: (qmail 50657 invoked by alias); 14 Dec 2017 19:12:43 -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 50640 invoked by uid 89); 14 Dec 2017 19:12:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Dec 2017 19:12:41 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBEJ9XSX115526 for ; Thu, 14 Dec 2017 14:12:39 -0500 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2euvsgpau3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 14 Dec 2017 14:12:39 -0500 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Dec 2017 14:12:38 -0500 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 14 Dec 2017 14:12:37 -0500 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBEJCbD740501444; Thu, 14 Dec 2017 19:12:37 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63441AE03B; Thu, 14 Dec 2017 14:13:38 -0500 (EST) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.28]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 34FF9AE03C; Thu, 14 Dec 2017 14:13:38 -0500 (EST) To: GCC Patches Cc: Richard Biener , Jakub Jelinek From: Bill Schmidt Subject: [PATCH] Slight cost adjustment in SLSR Date: Thu, 14 Dec 2017 13:12:36 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17121419-0052-0000-0000-0000029156C1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008204; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00960215; UDB=6.00485690; IPR=6.00740231; BA=6.00005740; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018544; XFM=3.00000015; UTC=2017-12-14 19:12:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121419-0053-0000-0000-000052E8FF1A Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-14_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712140262 X-IsSubscribed: yes Hi, While looking at PR83253, I noticed that the cost model for MULT_EXPR replacement can be improved. Right now we use mult_by_coeff_cost to determine the value of the possible replacement, but we use mul_cost to determine the savings from removing the original expression. This overcounts the savings when the expression being replaced is a multiply by a constant. In such cases we can again use mult_by_coeff_cost to determine the savings. This will reduce the chance of making an unprofitable replacement. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this okay for trunk? Thanks, Bill 2017-12-14 Bill Schmidt * gimple-ssa-strength-reduction.c (analyze_increments): Distinguish replacement costs for constant strides from those for unknown strides. Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 255588) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -3083,7 +3083,17 @@ analyze_increments (slsr_cand_t first_dep, machine else if (first_dep->kind == CAND_MULT) { int cost = mult_by_coeff_cost (incr, mode, speed); - int repl_savings = mul_cost (speed, mode) - add_cost (speed, mode); + int repl_savings; + + if (tree_fits_shwi_p (first_dep->stride)) + { + HOST_WIDE_INT hwi_stride = tree_to_shwi (first_dep->stride); + repl_savings = mult_by_coeff_cost (hwi_stride, mode, speed); + } + else + repl_savings = mul_cost (speed, mode); + repl_savings -= add_cost (speed, mode); + if (speed) cost = lowest_cost_path (cost, repl_savings, first_dep, incr_vec[i].incr, COUNT_PHIS);