From patchwork Thu Sep 12 17:19:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1984776 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=Pfg6UyVU; 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 4X4PMy4Ppfz1y1C for ; Fri, 13 Sep 2024 03:20:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B23B73858C98 for ; Thu, 12 Sep 2024 17:20:28 +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 7D5E13858D28 for ; Thu, 12 Sep 2024 17:20:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D5E13858D28 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 7D5E13858D28 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=1726161609; cv=none; b=hyBZ8S1WpfGTOt8v5qtahggct3vGoMaxqO3h71hQyaOeB/s/8NZP3xedzBgJCH7jh3+b+4Rkh/qZAX79/AVXhgq9NqjnbIk5jSqI88igxozryMUOU+VhiOjv7tB4Xsj1+uR6IJawM98CHJ2xUsIea8oMBAVFUhBUMw2frPcWoz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726161609; c=relaxed/simple; bh=30rA0ryUA6PHxJRdXSGrWjNdy4pZOj1hrEfCGwWEmM8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=X/rl4UbdkryvfjBP80eCZQ9BQw0lLZxbLg5rEvGzwXL1BwcR3tFcB7pb0P188X2WnDkxMZnG+LZOZbOz21rzOwnjJ64acl/GpF3WRzE9/6jE8N8ZSLjrOWHXyoOMJS5ca98H8xQob26WrkVc2grsGa9TfOFpiCxRpy4jimBRlrY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48CCEHK3004942 for ; Thu, 12 Sep 2024 17:20:07 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=OxAcDs5im6YF31xVMb+elA YrhoJ3nxORyxaM/n52COc=; b=Pfg6UyVUa24I1OObJM5oSKfEd/EosqdFREC011 Jom5gJwTP/Ef//h/cR4F1J+CGERezZEaJ8TUanNU61hTo4Rs/tdrF8DZ+ZW17J9i 5WF8F7F8azipXOE4pPixSZZlAV9H+88tJatPEd3AaTdBk2sLfdDWx7QEgzbyM9m3 j2gxO+SsODat+GsP+eixzhAu2bLnL7Y6g0TMCnCWuv/R8nmewhrDpgZ4BygtsEuF zc5ktCZ3l/YPAbKKGu+BW8ztEHBG/Z6axyzsH5gbadML4klxd/IkzLs5wdOneMF9 6w/V9erECxnenFvlVjh2ITDm92N8+K1tsvXQRJCu2wmAGeWQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy51e3nb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 12 Sep 2024 17:20:06 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 48CHK5lj025456 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 12 Sep 2024 17:20: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; Thu, 12 Sep 2024 10:20:05 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] Fix factor_out_conditional_operation heuristics for constants Date: Thu, 12 Sep 2024 10:19:53 -0700 Message-ID: <20240912171953.3392313-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-ORIG-GUID: IRDac1gu0qK4HYrV-MECYpitvcs735TU X-Proofpoint-GUID: IRDac1gu0qK4HYrV-MECYpitvcs735TU 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-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 mlxscore=0 bulkscore=0 mlxlogscore=894 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 phishscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409120128 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 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 a different patch, I noticed the heuristics were not doing the right thing if there was statements before the NOP/PREDICTs. (LABELS don't have other statements before them). This fixes that oversight which was added in r15-3334-gceda727dafba6e. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_operation): Instead of just ignorning a NOP/PREDICT, skip over them before checking the heuristics. Signed-off-by: Andrew Pinski --- gcc/tree-ssa-phiopt.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 5710bc32e61..e5413e40572 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -332,15 +332,17 @@ factor_out_conditional_operation (edge e0, edge e1, gphi *phi, { gsi = gsi_for_stmt (arg0_def_stmt); gsi_prev_nondebug (&gsi); + /* Ignore nops, predicates and labels. */ + while (!gsi_end_p (gsi) + && (gimple_code (gsi_stmt (gsi)) == GIMPLE_NOP + || gimple_code (gsi_stmt (gsi)) == GIMPLE_PREDICT + || gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)) + gsi_prev_nondebug (&gsi); + if (!gsi_end_p (gsi)) { gimple *stmt = gsi_stmt (gsi); - /* Ignore nops, predicates and labels. */ - if (gimple_code (stmt) == GIMPLE_NOP - || gimple_code (stmt) == GIMPLE_PREDICT - || gimple_code (stmt) == GIMPLE_LABEL) - ; - else if (gassign *assign = dyn_cast (stmt)) + if (gassign *assign = dyn_cast (stmt)) { tree lhs = gimple_assign_lhs (assign); enum tree_code ass_code