From patchwork Fri Jul 26 04:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1965180 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=m+hxPLfn; 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 4WVZht4Fnbz20FJ for ; Fri, 26 Jul 2024 14:36:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DCF1385C6CB for ; Fri, 26 Jul 2024 04:36:43 +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 4BD513858D20 for ; Fri, 26 Jul 2024 04:36:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4BD513858D20 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 4BD513858D20 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=1721968578; cv=none; b=X2Ea8mT4YCgg7i4VzcvIwt5VH/lrxY5ccSo2LUf9RhxjqlYt9xQAa7jcxTg0haEkC6XWOPfuxH3OH09WFlExUPu9dZENe7qQfefyiUXuhPi/UGnJQjiX3CmpKZRXNhrDB7xoeoIvCBe6UKl1uVx/24Sdh/dpdXhwDQD8164P084= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721968578; c=relaxed/simple; bh=VfKGgqHWKnCtbI4mPpADAmdTS3R4FwZocTfYpZDgmtQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nzOTPIu7MiEJwxlNU1Slze80KmM+BsScSCec2T1YAXdzpyIg5PgdXPJiccjlQMU6dILK+GHM7pfJ3al9W+ELohlJMR7coiD0birplUm5/bTaPfGpXPA4AZcf1bZK9PNwfijo2GmH02r5b9jiFAUBkBK9Z5upzKJseXKThEClQAs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46Q13O8E011892 for ; Fri, 26 Jul 2024 04:36:14 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=Be/wzW7x11s8795GtCa6Cs O2I1MIvsZLZi02i3yYq0Q=; b=m+hxPLfnkQWmEUF30+TBtVZJ6H1P5zQGJCUShC Ynug6Cp9UYRkcSK6guk5adlARbLD6HxWhJ5b1BIkPhLSp7FEGPZS+WbhWCclN5Sy 3A4VHL94TDYhB9X9eO9yAHNvQx6lMQgEbk/a1qc58aRdSloazVd1S9okS1L4j2qd OxiP72/dX09DnSC8PwY5pN8z8yI3kt/hZYufnBRvtJ4Nl+lsBs4lx9bVsKlDa2Qe 8Pwusby8CputSUUPKOxovG2KWUHpgEYHjvWxYKET0yE74PhKJM0QRTuKjYps9E14 vr1RdsVtemVY0gYwM9aO+PhSOgETudePWOQM5ytHvVAyKefw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40m1srgbpj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Jul 2024 04:36:13 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 46Q4aCdP023968 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Jul 2024 04:36:12 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, 25 Jul 2024 21:36:12 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 1/3] isel: Move duplicate comparisons to its own function Date: Thu, 25 Jul 2024 21:35:58 -0700 Message-ID: <20240726043600.47858-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: L9g1wWgSVkBBeK1pby5S4uoq8vEDddMN X-Proofpoint-ORIG-GUID: L9g1wWgSVkBBeK1pby5S4uoq8vEDddMN 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-07-26_01,2024-07-25_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=859 suspectscore=0 adultscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2407260030 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, SPF_HELO_NONE, SPF_NONE, TXREP 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 just a small cleanup to isel and no functional changes just. The loop inside pass_gimple_isel::execute looked was getting too deap so let's fix that by moving it to its own function. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * gimple-isel.cc (pass_gimple_isel::execute): Factor out duplicate comparisons out to ... (duplicate_comparison): New function. Signed-off-by: Andrew Pinski --- gcc/gimple-isel.cc | 66 ++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc index 57f7281bb50..327a78ea408 100644 --- a/gcc/gimple-isel.cc +++ b/gcc/gimple-isel.cc @@ -395,6 +395,40 @@ gimple_expand_vec_cond_expr (struct function *fun, gimple_stmt_iterator *gsi, 5, op0a, op0b, op1, op2, tcode_tree); } +/* Duplicate COND_EXPR condition defs of STMT located in BB when they are + comparisons so RTL expansion with the help of TER + can perform better if conversion. */ +static void +duplicate_comparison (gassign *stmt, basic_block bb) +{ + imm_use_iterator imm_iter; + use_operand_p use_p; + auto_vec cond_exprs; + unsigned cnt = 0; + tree lhs = gimple_assign_lhs (stmt); + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) + { + if (is_gimple_debug (USE_STMT (use_p))) + continue; + cnt++; + if (gimple_bb (USE_STMT (use_p)) == bb + && is_gimple_assign (USE_STMT (use_p)) + && gimple_assign_rhs1_ptr (USE_STMT (use_p)) == use_p->use + && gimple_assign_rhs_code (USE_STMT (use_p)) == COND_EXPR) + cond_exprs.safe_push (as_a (USE_STMT (use_p))); + } + for (unsigned i = cond_exprs.length () == cnt ? 1 : 0; + i < cond_exprs.length (); ++i) + { + gassign *copy = as_a (gimple_copy (stmt)); + tree new_def = duplicate_ssa_name (lhs, copy); + gimple_assign_set_lhs (copy, new_def); + auto gsi2 = gsi_for_stmt (cond_exprs[i]); + gsi_insert_before (&gsi2, copy, GSI_SAME_STMT); + gimple_assign_set_rhs1 (cond_exprs[i], new_def); + update_stmt (cond_exprs[i]); + } +} namespace { @@ -469,37 +503,7 @@ pass_gimple_isel::execute (struct function *fun) tree lhs = gimple_assign_lhs (stmt); if (TREE_CODE_CLASS (code) == tcc_comparison && !has_single_use (lhs)) - { - /* Duplicate COND_EXPR condition defs when they are - comparisons so RTL expansion with the help of TER - can perform better if conversion. */ - imm_use_iterator imm_iter; - use_operand_p use_p; - auto_vec cond_exprs; - unsigned cnt = 0; - FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) - { - if (is_gimple_debug (USE_STMT (use_p))) - continue; - cnt++; - if (gimple_bb (USE_STMT (use_p)) == bb - && is_gimple_assign (USE_STMT (use_p)) - && gimple_assign_rhs1_ptr (USE_STMT (use_p)) == use_p->use - && gimple_assign_rhs_code (USE_STMT (use_p)) == COND_EXPR) - cond_exprs.safe_push (as_a (USE_STMT (use_p))); - } - for (unsigned i = cond_exprs.length () == cnt ? 1 : 0; - i < cond_exprs.length (); ++i) - { - gassign *copy = as_a (gimple_copy (stmt)); - tree new_def = duplicate_ssa_name (lhs, copy); - gimple_assign_set_lhs (copy, new_def); - auto gsi2 = gsi_for_stmt (cond_exprs[i]); - gsi_insert_before (&gsi2, copy, GSI_SAME_STMT); - gimple_assign_set_rhs1 (cond_exprs[i], new_def); - update_stmt (cond_exprs[i]); - } - } + duplicate_comparison (stmt, bb); } }