From patchwork Wed Aug 28 04:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1977579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=nbUMFmjm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wts4f19phz1yfn for ; Wed, 28 Aug 2024 14:34:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEFEF386076C for ; Wed, 28 Aug 2024 04:34:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id 611D13858C66 for ; Wed, 28 Aug 2024 04:33:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 611D13858C66 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 611D13858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724819625; cv=none; b=XuWxzcMfQhHAK1TGa+AfqkiUdRbNy6hRAh6RjEC1+rsquXr26vUTLiDGkeddHC66EbnytAcXncCiPiiV7blEtVK2HmtBfRNZ9YAIFV+BBS0APO0HacfP5ftjOrLLfLltYh1+QtYLv+MmVqqrspNESAcRkcvLV1geNecJOT1xdc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724819625; c=relaxed/simple; bh=mzisEHofUXrL18ydAAd3eJOsQ4JR0yWOoQGzjU+Jsqw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UhvF9ZOnDRHqS7E1SnfKaquv71WRBG84mHXTUfjWTl8d4ev2S83KBPLBo1NWZPZ4jf6xhRzXXeaBdbTHm2YhaOItIjfAjVkEyiRyvC81GWt2xup0HYKqobu1Q6SR+ESX1obldGCqkk2JMl0Wsg2+fX30Qy7CynF2RL7o/vdJ86g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47RLaBK5022267 for ; Wed, 28 Aug 2024 04:33:42 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=FPjE4GOxRGDRRrKJqRz09/ CbVmCKD2Vx3NqBE3ozH0g=; b=nbUMFmjmAoKdbs06VPb1fhiTCYV0tK1BN5FTMZ hGDkc0yF6lTWMv6NMEip7MexznEUp5frDIILhaXco/vLPGUrvkx5fELFcpevCQ/q 7pqVgjETwHON0gUCIheeA9fOgtoh0OwzfHdfxfDGna/1Fkb/TPPBMuU6Dku02VCl Tw3QHxMycGsol53cP08xJ4SjlALsajM/wqzcu39Iy/VjnU74B6Pi1xDLCge5Y1/8 s7hgvXOYh7y40x4KnTauARcuFCtqUeVrrr//xDw3m4mhWgirZw5sfXfgtoKBnhoa CytyGTn2rW85l20nMrBKoaai7JXZcwY9K07G34k3Howl71Ng== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 419pv10nfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Aug 2024 04:33:42 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 47S4XfdF026084 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Aug 2024 04:33:41 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, 27 Aug 2024 21:33:41 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 1/3] expand: Add debug dump on the cost for `popcount==1` expand Date: Tue, 27 Aug 2024 21:33:29 -0700 Message-ID: <20240828043331.3359171-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: nalasex01a.na.qualcomm.com (10.47.209.196) 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: 422th5vRFQx3RZ-7QLSGAwgU_xxEJNMX X-Proofpoint-ORIG-GUID: 422th5vRFQx3RZ-7QLSGAwgU_xxEJNMX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-28_02,2024-08-27_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 bulkscore=0 mlxlogscore=486 impostorscore=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408280029 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~incoming=patchwork.ozlabs.org@gcc.gnu.org While working on PR 114224, I found it would be useful to dump the different costs of the expansion to make easier to understand why one was chosen over the other. Bootstrapped and tested on x86_64-linux-gnu. Build and tested for aarch64-linux-gnu. gcc/ChangeLog: * internal-fn.cc (expand_POPCOUNT): Dump the costs for the two choices. --- gcc/internal-fn.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index 89da13b38ce..91210976a0a 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -5351,6 +5351,14 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt) unsigned popcount_cost = (seq_cost (popcount_insns, speed_p) + seq_cost (popcount_cmp_insns, speed_p)); unsigned cmp_cost = seq_cost (cmp_insns, speed_p); + + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf(dump_file, "popcount == 1, cost\n"); + fprintf(dump_file, "popcount: %u\n", popcount_cost); + fprintf(dump_file, "cmp: %u\n\n", cmp_cost); + } + if (popcount_cost <= cmp_cost) emit_insn (popcount_insns); else