From patchwork Thu Aug 29 23:01:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1978643 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=gw3BcMkY; 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 4Wvxcf3z7Nz1yZ9 for ; Fri, 30 Aug 2024 09:02:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51AB3386180B for ; Thu, 29 Aug 2024 23:02:08 +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 46569385C6C8 for ; Thu, 29 Aug 2024 23:01:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46569385C6C8 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 46569385C6C8 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=1724972502; cv=none; b=E2GvrLxSsrXX4QV+MmbwnmVS9sh/2lNMkK6DTwj6PFdbBdg3HhWbMW+tOiDxhd+FOuK3bA+LxCQGfsGDJELoWH61dLKOi2oohhewU+wUPNxLU9wErQWhskiV7Kom6anhOYb2AVOqlyV0KUDxCV9o+VJDslF9ybaSzXEQXBWZjww= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724972502; c=relaxed/simple; bh=VjxP57FOlefqTR8Ws5wOalfEHRMPSOCccOiORORRDWE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=U5+5wQcNrPjgzdp2uRUpsOe319lGnB/Eu4TatWtj4q2HKsp+vQkgzW9yvdQx/SZSG7tpgd8xOn5LsmoQANU/c0bjpaEdSdcUrd2pw8JKQvJr1wNIivxD7sJPvvq1ez1ayyYXM49NhPTCD84URh2VKDCZjpUU8ZapmNe+AqjXgi0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47TGd0Kb030353 for ; Thu, 29 Aug 2024 23:01:40 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=QZwNQ+gBTDho9nfmN8XF4k jMbCB0PK3EGivFMOIkJLE=; b=gw3BcMkYZXCzl8wYTqttMjVt5b/kYuZbrWZ9HO lHARbXQrcUWfP73K8T8scOZkSaEXzYm+zCHH4xV2j9TdeBOP9o8RQI7+QxVRH6FR YInERmc+CpC/hEV9lr0x7Y2usfSFUTZo+Jp7NKI696pGrJ2Wlm1o1SGblBC1WiGr iHUZkAkEV2phMwbQvB8vBqU/kOjtXbA2E+UDCY/JuPJ4hUUcs+mzNFAF3huXdzAh zpUtjP5yJymNx8lmnBogqCKcp7qDnIV2psLuREpNJ0lODNzNzphSDcZ+GI5P0iKe 5/fOAWWfozwOvZWm+poULfjNvWkq6mkIlfbhaNYD+PtIFB/Q== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 419puuesgk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 29 Aug 2024 23:01:39 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 47TN1djh005720 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 29 Aug 2024 23:01:39 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; Thu, 29 Aug 2024 16:01:38 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 1/2] expand: Small speed up expansion of __builtin_prefetch Date: Thu, 29 Aug 2024 16:01:27 -0700 Message-ID: <20240829230128.123207-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: nalasex01c.na.qualcomm.com (10.47.97.35) 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: Y4jkMdUe7q75X-3Sn9DwWG6egLY8SFp_ X-Proofpoint-ORIG-GUID: Y4jkMdUe7q75X-3Sn9DwWG6egLY8SFp_ 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-29_06,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 clxscore=1015 mlxlogscore=539 mlxscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408290164 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 This is a small speed up of the expansion of __builtin_prefetch. Basically for the optional arguments, no reason to call expand_normal on a constant integer that we know the value, just replace it with GEN_INT/const0_rtx instead. Bootstrapped and tested on x86_64-linux. gcc/ChangeLog: * builtins.cc (expand_builtin_prefetch): Rewrite expansion of the optional arguments to not expand known constants. --- gcc/builtins.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index b4d51eaeba5..37c7c98e5c7 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -1280,25 +1280,22 @@ expand_builtin_prefetch (tree exp) zero (read) and argument 2 (locality) defaults to 3 (high degree of locality). */ nargs = call_expr_nargs (exp); - if (nargs > 1) - arg1 = CALL_EXPR_ARG (exp, 1); - else - arg1 = integer_zero_node; - if (nargs > 2) - arg2 = CALL_EXPR_ARG (exp, 2); - else - arg2 = integer_three_node; + arg1 = nargs > 1 ? CALL_EXPR_ARG (exp, 1) : NULL_TREE; + arg2 = nargs > 2 ? CALL_EXPR_ARG (exp, 2) : NULL_TREE; /* Argument 0 is an address. */ op0 = expand_expr (arg0, NULL_RTX, Pmode, EXPAND_NORMAL); /* Argument 1 (read/write flag) must be a compile-time constant int. */ - if (TREE_CODE (arg1) != INTEGER_CST) + if (arg1 == NULL_TREE) + op1 = const0_rtx; + else if (TREE_CODE (arg1) != INTEGER_CST) { error ("second argument to %<__builtin_prefetch%> must be a constant"); - arg1 = integer_zero_node; + op1 = const0_rtx; } - op1 = expand_normal (arg1); + else + op1 = expand_normal (arg1); /* Argument 1 must be either zero or one. */ if (INTVAL (op1) != 0 && INTVAL (op1) != 1) { @@ -1308,12 +1305,15 @@ expand_builtin_prefetch (tree exp) } /* Argument 2 (locality) must be a compile-time constant int. */ - if (TREE_CODE (arg2) != INTEGER_CST) + if (arg2 == NULL_TREE) + op2 = GEN_INT (3); + else if (TREE_CODE (arg2) != INTEGER_CST) { error ("third argument to %<__builtin_prefetch%> must be a constant"); - arg2 = integer_zero_node; + op2 = const0_rtx; } - op2 = expand_normal (arg2); + else + op2 = expand_normal (arg2); /* Argument 2 must be 0, 1, 2, or 3. */ if (INTVAL (op2) < 0 || INTVAL (op2) > 3) { From patchwork Thu Aug 29 23:01:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1978644 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=L43fTIuA; 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 4Wvxcf4Pllz1ygJ for ; Fri, 30 Aug 2024 09:02:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 649083861825 for ; Thu, 29 Aug 2024 23:02:08 +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 8A2EF385EC1B for ; Thu, 29 Aug 2024 23:01:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A2EF385EC1B 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 8A2EF385EC1B 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=1724972503; cv=none; b=rZYWtr/DCNVTXC8L9fI6aYCdO3OkbcNtenDtI6GFQUEdh1u65g1cKFlsVLtJ9dx4RB18WW2fZ0YzYybZnqvggp4z/MGPaLAk/LI2wM5n+hbz23Opy1250NCYdKBFymZdogtYgPsQhYqxSJolK0UTW1zSFVegKgD/Z2zKyokpXqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724972503; c=relaxed/simple; bh=P+9WKwa/WoI24RsT8FaAndbGZIttT/++UMQhvWt2FyY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ULR7azV1Qh9RxsQOPo3ZRKMiDXCGMEXdGTk3FrDTbcK4xwu4xdHpvNkhCVF9ABfpg2EnQcZfb7eSOBzuNENgVMj8hBE16uIlDxPj3StdOWRSDs+gXOOB4zmdYQNb9AOG86yN+iD4rdvP9/Q1hPY9Oy8OH7dVCG3ADY5ODgk6p+Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47THVAK7026547 for ; Thu, 29 Aug 2024 23:01:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= cjMqz7P3+JcqpHJNDugJ22e61bzSEK+iTLtGzoz9gGU=; b=L43fTIuAC6L8MXlw OAif0b8GZtSGkXtv6aICqIUF5QjqKTglZBYtOlSqHIgCEQ9Y5/rTQKYFGtRVMLVG Rh1fZAl2ahMZIn7EUtzUHjnuwkQvtYEA+XjXqIXeIKOLACMX4ptz9f2IATiAvfv6 spq1OJY+pti2BNxIOwe1dDD2tr3zzh9CRIT3zkXzAr1XJUjuIfDonIlVWKeCFJpK dp3+GeDotQph42LQmjqyO6FOApo4T+FeEnBILYjHH9xE2jE1ShszSl873Yt6pKwz U6r0WTjAMWhTw/x9Qa/0607sv4pjl3nXEn+6c5q7zgZfRqGaHwQL120EJXCdp4Ql YzJEfA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 419puveurr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 29 Aug 2024 23:01:40 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 47TN1dqh031789 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 29 Aug 2024 23:01:39 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; Thu, 29 Aug 2024 16:01:39 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 2/2] middle-end: Remove integer_three_node [PR116537] Date: Thu, 29 Aug 2024 16:01:28 -0700 Message-ID: <20240829230128.123207-2-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240829230128.123207-1-quic_apinski@quicinc.com> References: <20240829230128.123207-1-quic_apinski@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) 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-ORIG-GUID: f29ssMbrE8kyfb4BJUFRlYMoQ7jdwc4q X-Proofpoint-GUID: f29ssMbrE8kyfb4BJUFRlYMoQ7jdwc4q 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-29_06,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=812 priorityscore=1501 bulkscore=0 impostorscore=0 adultscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408290164 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 After the small expansion patch for __builtin_prefetch, the only use of integer_three_node is inside tree-ssa-loop-prefetch.cc so let's remove it as the loop prefetch pass is not enabled these days by default and having a tree node around just for that pass is a little wasteful. Integer constants are also shared these days so calling build_int_cst will use the cached node anyways. Bootstrapped and tested on x86_64-linux. PR middle-end/116537 gcc/ChangeLog: * tree-core.h (enum tree_index): Remove TI_INTEGER_THREE * tree-ssa-loop-prefetch.cc (issue_prefetch_ref): Call build_int_cst instead of using integer_three_node. * tree.cc (build_common_tree_nodes): Remove initialization of integer_three_node. * tree.h (integer_three_node): Delete. Signed-off-by: Andrew Pinski --- gcc/tree-core.h | 1 - gcc/tree-ssa-loop-prefetch.cc | 2 +- gcc/tree.cc | 1 - gcc/tree.h | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 27c569c7702..a36817059da 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -662,7 +662,6 @@ enum tree_index : unsigned { TI_INTEGER_ZERO, TI_INTEGER_ONE, - TI_INTEGER_THREE, TI_INTEGER_MINUS_ONE, TI_NULL_POINTER, diff --git a/gcc/tree-ssa-loop-prefetch.cc b/gcc/tree-ssa-loop-prefetch.cc index bb5d5dec779..3569403c618 100644 --- a/gcc/tree-ssa-loop-prefetch.cc +++ b/gcc/tree-ssa-loop-prefetch.cc @@ -1182,7 +1182,7 @@ issue_prefetch_ref (struct mem_ref *ref, unsigned unroll_factor, unsigned ahead) addr_base = force_gimple_operand_gsi (&bsi, unshare_expr (addr_base), true, NULL, true, GSI_SAME_STMT); write_p = ref->write_p ? integer_one_node : integer_zero_node; - local = nontemporal ? integer_zero_node : integer_three_node; + local = nontemporal ? integer_zero_node : build_int_cst (integer_type_node, 3); for (ap = 0; ap < n_prefetches; ap++) { diff --git a/gcc/tree.cc b/gcc/tree.cc index 17a5cea7c25..b14cfbe7929 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -9567,7 +9567,6 @@ build_common_tree_nodes (bool signed_char) /* Define these next since types below may used them. */ integer_zero_node = build_int_cst (integer_type_node, 0); integer_one_node = build_int_cst (integer_type_node, 1); - integer_three_node = build_int_cst (integer_type_node, 3); integer_minus_one_node = build_int_cst (integer_type_node, -1); size_zero_node = size_int (0); diff --git a/gcc/tree.h b/gcc/tree.h index c501019717f..93aa7d22d6f 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4444,7 +4444,6 @@ tree_strip_any_location_wrapper (tree exp) #define integer_zero_node global_trees[TI_INTEGER_ZERO] #define integer_one_node global_trees[TI_INTEGER_ONE] -#define integer_three_node global_trees[TI_INTEGER_THREE] #define integer_minus_one_node global_trees[TI_INTEGER_MINUS_ONE] #define size_zero_node global_trees[TI_SIZE_ZERO] #define size_one_node global_trees[TI_SIZE_ONE]