From patchwork Wed Sep 4 01:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 97021 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97809385EC12 for ; Wed, 4 Sep 2024 02:00:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id EFEF73858D39 for ; Wed, 4 Sep 2024 01:59:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFEF73858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EFEF73858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725415182; cv=none; b=RMkn1Wr0/wlvD9G/SPxXVBqHga6Ly80RJg4ciFDglYNWD9NdbT436w3rXe0hd577Pgbxx66nsXKSIu348UaSVRj8MPrkfsRX7tVWlMe4+DqsYAr5tbq9dTuqGSk3oQSETVoKWWkWDld7rUwEY5WMAeyYNTIAj7krm8T1M1wA10g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725415182; c=relaxed/simple; bh=aQpUbY2zzFZdDCIPzUBdsYewobgkD+Nx9e+DCr4rjhQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ub23XJJ4AVER5WcH9on/HfllECeGG7LhYw8MQjNKce+1Ct+9JBtm9WhJfABIYy++IT9ozMJvTO7SYEkPR7gGslPc0yyhKE6iz/D4LEmc5lPH97VpLevmxc2BQQBrbD535KupN2CsnHGdDa1BDHihyRwI9C4whwpoLp+k+AHNT0A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483Nc0jq014493 for ; Wed, 4 Sep 2024 01:59:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=Tghw8LpA+mcSKoQIOZB2rB 3gIjpo/5IErEfkwHrpaUM=; b=QGHvsdx7Z1psYjwkK7c5ecH595XXLCf7iHkOV3 1a7OKz67uXqvgL/qLwZOLOnpZDLbRzlaat/UOqmdA/W4Dx4ZPq+Inc6LrM/qSNOr edjg6sRnlvLS5MxBp9aZIQkaFPUeVahb6Coc0gDif1SsBhRtVmuaGd9it0gOSUkc aKGVc5lKlWD5CUCRLDQQmTA6KbKEdQNCh1hjZfsI0Q/nHq7tvvGg+w9CPQbq9C8l ue58ZoNITxoBF0xMChKLyHD4qb/943sRtrKsH4A5AS+6jgUtOAje9accsKYesCvY SStwnauDnWtitl9lkrDsBV0A/oIqGFZezr5THPdmTYHngstA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41dt69bbnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 04 Sep 2024 01:59:30 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4841xToI016803 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 4 Sep 2024 01:59:29 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 3 Sep 2024 18:59:28 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] expand: Add dump for costing of positive divides Date: Tue, 3 Sep 2024 18:59:14 -0700 Message-ID: <20240904015914.2874499-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: ZiMJ-cRFzDdBvScx3xMwbbh6293aTE_1 X-Proofpoint-ORIG-GUID: ZiMJ-cRFzDdBvScx3xMwbbh6293aTE_1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_13,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxlogscore=571 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040012 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org While trying to understand PR 115910 I found it was useful to print out the two costs of doing a signed and unsigned division just like was added in r15-3272-g3c89c41991d8e8 for popcount==1. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * expr.cc (expand_expr_divmod): Add dump of the two costs for positive division. Signed-off-by: Andrew Pinski --- gcc/expr.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/expr.cc b/gcc/expr.cc index 320be8b17a1..7a471f20e79 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -9648,6 +9648,7 @@ expand_expr_divmod (tree_code code, machine_mode mode, tree treeop0, end_sequence (); unsigned uns_cost = seq_cost (uns_insns, speed_p); unsigned sgn_cost = seq_cost (sgn_insns, speed_p); + bool was_tie = false; /* If costs are the same then use as tie breaker the other other factor. */ @@ -9655,8 +9656,14 @@ expand_expr_divmod (tree_code code, machine_mode mode, tree treeop0, { uns_cost = seq_cost (uns_insns, !speed_p); sgn_cost = seq_cost (sgn_insns, !speed_p); + was_tie = true; } + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf(dump_file, "positive division:%s unsigned cost: %u; " + "signed cost: %u\n", was_tie ? "(needed tie breaker)":"", + uns_cost, sgn_cost); + if (uns_cost < sgn_cost || (uns_cost == sgn_cost && unsignedp)) { emit_insn (uns_insns);