From patchwork Tue Sep 3 23:57:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1980382 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=VcWAh96p; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4Wz2dM2VkSz1yg3 for ; Wed, 4 Sep 2024 09:58:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5DAA385EC38 for ; Tue, 3 Sep 2024 23:58:27 +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 6207A3858D39 for ; Tue, 3 Sep 2024 23:58:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6207A3858D39 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 6207A3858D39 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=1725407889; cv=none; b=tJG2h/TY4BrRoCfYHvjOlkBQAJ0guztM1IevJ9T8uhIAKw9fQiF8BnCZxhOQXJYW0uIw/gpS/Ssb682AeIwA3VEgW46VcBhK2OSrNHXDjd0s6L0ZVz85ET7k9eyqVAoqhuyVxsj7DkpHKWtrfyNWpBJtRzbBaTrZtoNanRxZGlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725407889; c=relaxed/simple; bh=D/nCcIuCM1kRSkldZ1kbSZaICmPa5bNIT1/EofVktdA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=d3j9VQuHKIyrUyN/4wz+www88klbGSyNzrZnh3TK72yBHRMB7b8Z7XPUetzmQNlOsThhGXLl4Q8AoMrYyR7B4Qe5hVVcBkRGJ8pDKYfmYCgydSFsGvJw8PnmAa4RYgpyHfUqYPJ18howRO+O+wlVmxn0XEyQmG5WiK51xhyqd+8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483MAXld029627 for ; Tue, 3 Sep 2024 23:58:06 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=vHfeAa8S7UHK4SzhSJBN+5 eSMqmb21hvhaARVsp6xRw=; b=VcWAh96pjpGWsuvlw15OOcOoRKNuUTsJv/dcIc oFyK4GW3Wr1t3EH5FVAhH/fjCYA1M+GNqfHl4hLiUMghKG61jZqmxjjJjvcfb+FN iaoKq+BDfpaXUw1LBRv6zdNvBH/5tuDG0bPLQkxLLuxqlFKa1nfuWdqNSV1bnBv4 kCe77PcZ85t+s3TTWLcvLrV8TkdTPUCeevL2g+Fmk4IkDIUwaVXzwDjdIVSpmojI uO1nVUhb3mxe8X9mMK1KZ+HEfcSBlBl5e5lIH/8w+I2OdlS8HnIhKzO2tfevAKpR qmnz5CTuzS/4e2N6jehcG0oGECZwN44s4MyLzg/i2S5g4hKw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41brvf188p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Sep 2024 23:58:06 +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 483Nw5eK026363 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 3 Sep 2024 23:58:05 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 16:58:05 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] object-size: Use simple_dce_from_worklist in object-size pass Date: Tue, 3 Sep 2024 16:57:54 -0700 Message-ID: <20240903235754.2829849-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: jtOtUdhrURLRFvYoKCvomHujbT4sQRhe X-Proofpoint-ORIG-GUID: jtOtUdhrURLRFvYoKCvomHujbT4sQRhe 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_11,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 adultscore=0 mlxlogscore=874 priorityscore=1501 malwarescore=0 spamscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409030191 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 trying to see if there was a way to improve object-size pass to use the ranger (for pointer plus), I noticed that it leaves around the statement containing __builtin_object_size if it was reduced to a constant. This fixes that by using simple_dce_from_worklist. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-object-size.cc (object_sizes_execute): Mark lhs for maybe dceing if doing a propagate. Call simple_dce_from_worklist. Signed-off-by: Andrew Pinski --- gcc/tree-object-size.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc index 4c1fa9b555f..6544730e153 100644 --- a/gcc/tree-object-size.cc +++ b/gcc/tree-object-size.cc @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "gimplify-me.h" #include "gimplify.h" +#include "tree-ssa-dce.h" struct object_size_info { @@ -2187,6 +2188,7 @@ static unsigned int object_sizes_execute (function *fun, bool early) { todo = 0; + auto_bitmap sdce_worklist; basic_block bb; FOR_EACH_BB_FN (bb, fun) @@ -2277,13 +2279,18 @@ object_sizes_execute (function *fun, bool early) /* Propagate into all uses and fold those stmts. */ if (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) - replace_uses_by (lhs, result); + { + replace_uses_by (lhs, result); + /* Mark lhs as being possiblely DCEd. */ + bitmap_set_bit (sdce_worklist, SSA_NAME_VERSION (lhs)); + } else replace_call_with_value (&i, result); } } fini_object_sizes (); + simple_dce_from_worklist (sdce_worklist); return todo; }