From patchwork Mon May 23 10:55:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 54283 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1019F383A332 for ; Mon, 23 May 2022 10:55:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1019F383A332 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653303338; bh=RxztOda4BmiBgW22Bql32cxKI2zYrE8SX/tfJz9mX+w=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=H4VJo7vyQSkkd+5D1XQYJg1/Zmn1mZ/BQTUzJCAqPo9MA4Q0ptsNbq9bbBme0fhf/ I3rBkHhSS8C37k5nB5EchKSGPVjtPTAEzgxZEJlG1jzrkrh/wwhJA8Iag62+uJ+bah Uo6qF09pwgos3ZatJWSZHLeqVY1WRAa4xO/JKLJA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 2BCE93858010 for ; Mon, 23 May 2022 10:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2BCE93858010 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 618C61F8FC for ; Mon, 23 May 2022 10:55:07 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4E1F813AA5 for ; Mon, 23 May 2022 10:55:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nELYEQtoi2KdEAAAMHmgww (envelope-from ) for ; Mon, 23 May 2022 10:55:07 +0000 Date: Mon, 23 May 2022 12:55:06 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove forward_propagate_into_cond MIME-Version: 1.0 Message-Id: <20220523105507.4E1F813AA5@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This is a first cleanup opportunity from the COND_EXPR gimplification which allows us to remove now redundant forward_propagate_into_cond. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-05-23 Richard Biener * tree-ssa-forwprop.cc (forward_propagate_into_cond): Remove. (pass_forwprop::execute): Do not propagate into COND_EXPR conditions. --- gcc/tree-ssa-forwprop.cc | 79 +--------------------------------------- 1 file changed, 2 insertions(+), 77 deletions(-) diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index b582529c404..d698a483ff1 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -511,9 +511,7 @@ forward_propagate_into_comparison (gimple_stmt_iterator *gsi) /* Propagate from the ssa name definition statements of COND_EXPR in GIMPLE_COND statement STMT into the conditional if that simplifies it. Returns zero if no statement was changed, one if there were - changes and two if cfg_cleanup needs to run. - - This must be kept in sync with forward_propagate_into_cond. */ + changes and two if cfg_cleanup needs to run. */ static int forward_propagate_into_gimple_cond (gcond *stmt) @@ -573,70 +571,6 @@ forward_propagate_into_gimple_cond (gcond *stmt) return 0; } - -/* Propagate from the ssa name definition statements of COND_EXPR - in the rhs of statement STMT into the conditional if that simplifies it. - Returns true zero if the stmt was changed. */ - -static bool -forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) -{ - gimple *stmt = gsi_stmt (*gsi_p); - tree tmp = NULL_TREE; - tree cond = gimple_assign_rhs1 (stmt); - enum tree_code code = gimple_assign_rhs_code (stmt); - - /* We can do tree combining on SSA_NAME and comparison expressions. */ - if (COMPARISON_CLASS_P (cond)) - tmp = forward_propagate_into_comparison_1 (stmt, TREE_CODE (cond), - TREE_TYPE (cond), - TREE_OPERAND (cond, 0), - TREE_OPERAND (cond, 1)); - else if (TREE_CODE (cond) == SSA_NAME) - { - enum tree_code def_code; - tree name = cond; - gimple *def_stmt = get_prop_source_stmt (name, true, NULL); - if (!def_stmt || !can_propagate_from (def_stmt)) - return 0; - - def_code = gimple_assign_rhs_code (def_stmt); - if (TREE_CODE_CLASS (def_code) == tcc_comparison) - tmp = fold_build2_loc (gimple_location (def_stmt), - def_code, - TREE_TYPE (cond), - gimple_assign_rhs1 (def_stmt), - gimple_assign_rhs2 (def_stmt)); - } - - if (tmp - && is_gimple_val (tmp)) - { - if (dump_file) - { - fprintf (dump_file, " Replaced '"); - print_generic_expr (dump_file, cond); - fprintf (dump_file, "' with '"); - print_generic_expr (dump_file, tmp); - fprintf (dump_file, "'\n"); - } - - if ((code == VEC_COND_EXPR) ? integer_all_onesp (tmp) - : integer_onep (tmp)) - gimple_assign_set_rhs_from_tree (gsi_p, gimple_assign_rhs2 (stmt)); - else if (integer_zerop (tmp)) - gimple_assign_set_rhs_from_tree (gsi_p, gimple_assign_rhs3 (stmt)); - else - gimple_assign_set_rhs1 (stmt, unshare_expr (tmp)); - stmt = gsi_stmt (*gsi_p); - update_stmt (stmt); - - return true; - } - - return 0; -} - /* We've just substituted an ADDR_EXPR into stmt. Update all the relevant data structures to match. */ @@ -3720,16 +3654,7 @@ pass_forwprop::execute (function *fun) tree rhs1 = gimple_assign_rhs1 (stmt); enum tree_code code = gimple_assign_rhs_code (stmt); - if (code == COND_EXPR) - { - /* In this case the entire COND_EXPR is in rhs1. */ - if (forward_propagate_into_cond (&gsi)) - { - changed = true; - stmt = gsi_stmt (gsi); - } - } - else if (TREE_CODE_CLASS (code) == tcc_comparison) + if (TREE_CODE_CLASS (code) == tcc_comparison) { int did_something; did_something = forward_propagate_into_comparison (&gsi);