From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 3470F3875449 for ; Thu, 8 Oct 2020 18:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3470F3875449 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 098I2tib145862; Thu, 8 Oct 2020 14:19:27 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3427691f4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Oct 2020 14:19:27 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 098I3Vdt148779; Thu, 8 Oct 2020 14:19:26 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 3427691f14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Oct 2020 14:19:23 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 098IBPc6005503; Thu, 8 Oct 2020 18:19:22 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma02wdc.us.ibm.com with ESMTP id 341caraqxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Oct 2020 18:19:22 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 098IJMLH52232544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Oct 2020 18:19:22 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B9D4112061; Thu, 8 Oct 2020 18:19:22 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C593D112063; Thu, 8 Oct 2020 18:19:21 +0000 (GMT) Received: from lexx (unknown [9.211.77.93]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 8 Oct 2020 18:19:21 +0000 (GMT) Message-ID: Subject: Re: [PATCH 7/8] [RS6000] rs6000_rtx_costs reduce cost for SETs From: will schmidt To: Alan Modra , gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org Date: Thu, 08 Oct 2020 13:19:21 -0500 In-Reply-To: <20201007225800.9536-8-amodra@gmail.com> References: <20201007225800.9536-1-amodra@gmail.com> <20201007225800.9536-8-amodra@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-8.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-10-08_12:2020-10-08, 2020-10-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 malwarescore=0 suspectscore=0 impostorscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2010080131 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2020 18:19:30 -0000 On Thu, 2020-10-08 at 09:27 +1030, Alan Modra via Gcc-patches wrote: > The aim of this patch is to make rtx_costs for SETs closer to > insn_cost for SETs. One visible effect on powerpc code is increased > if-conversion. > > * config/rs6000/rs6000.c (rs6000_rtx_costs): Reduce cost of SET > operands. > > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > index 76aedbfae6f..d455aa52427 100644 > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -21684,6 +21684,35 @@ rs6000_rtx_costs (rtx x, machine_mode mode, > int outer_code, > } > return false; > > + case SET: > + /* On entry the value in *TOTAL is the number of general > purpose > + regs being set, multiplied by COSTS_N_INSNS (1). Handle > + costing of set operands specially since in most cases we have > + an instruction rather than just a piece of RTL and should > + return a cost comparable to insn_cost. That's a little > + complicated because in some cases the cost of SET operands is > + non-zero, see point 5 above and cost of PLUS for example, and > + in others it is zero, for example for (set (reg) (reg)). > + But (set (reg) (reg)) has the same insn_cost as > + (set (reg) (plus (reg) (reg))). Hack around this by > + subtracting COSTS_N_INSNS (1) from the operand cost in cases > + were we add at least COSTS_N_INSNS (1) for some operation. s/were/where/ :-) > + However, don't do so for constants. Constants might cost > + more than zero when they require more than one instruction, > + and we do want the cost of extra instructions. */ > + { > + rtx_code src_code = GET_CODE (SET_SRC (x)); > + if (src_code == CONST_INT > + || src_code == CONST_DOUBLE > + || src_code == CONST_WIDE_INT) > + return false; > + int set_cost = (rtx_cost (SET_SRC (x), mode, SET, 1, speed) > + + rtx_cost (SET_DEST (x), mode, SET, 0, > speed)); > + if (set_cost >= COSTS_N_INSNS (1)) > + *total += set_cost - COSTS_N_INSNS (1); > + return true; > + } > + > default: > return false; > } lgtm, thanks -Will