From patchwork Fri Jun 11 04:14:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1490719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VzhIhMuf; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G1SDW2YXrz9sVb for ; Fri, 11 Jun 2021 14:15:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AE773898521 for ; Fri, 11 Jun 2021 04:15:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AE773898521 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623384903; bh=r9KvR+/LyvW+0ZkaY2Q3ZnmehHqtLzF0vzvipq/WD5s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=VzhIhMufkeNTJbOq69Zn6UPaTqWKbWdsgh+0vSmgu44am75ekvdSR5KVQeStLBxcN 15SbksS2kOoGe7ONPLNxWj/v/LNAZauCrIlKkj4xmVa/wbJXARb2GxBLMDT+6w3Rvb NNe2egDQWXF04XWksLghoVf+z9XbzcQYxL0v0DBk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 05927385700A for ; Fri, 11 Jun 2021 04:14:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05927385700A Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15B47MUN007748 for ; Thu, 10 Jun 2021 21:14:42 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3934fv6j56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 10 Jun 2021 21:14:42 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Jun 2021 21:14:40 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Jun 2021 21:14:40 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.197]) by maili.marvell.com (Postfix) with ESMTP id 36DB33F7074; Thu, 10 Jun 2021 21:14:40 -0700 (PDT) To: Subject: [PATCH] Add statistics counting to PHI-OPT Date: Thu, 10 Jun 2021 21:14:35 -0700 Message-ID: <1623384875-27177-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 7M6JCnb4u5WBtqqRLF7AEkqGO9vX-GyO X-Proofpoint-GUID: 7M6JCnb4u5WBtqqRLF7AEkqGO9vX-GyO X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-11_01:2021-06-11, 2021-06-10 signatures=0 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: apinski--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: apinski@marvell.com Cc: Andrew Pinski Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Andrew Pinski This should have been done before I started to work on connecting PHI-OPT to match-and-simplify to see quickly if we miss anything but it is better late than never. Anyways there was no statistics counting in PHI-OPT before so adding it is the right thing to do. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.c (replace_phi_edge_with_variable): Add counting of how many times it is done. (factor_out_conditional_conversion): Likewise. (match_simplify_replacement): Likewise. (value_replacement): Likewise. (spaceship_replacement): Likewise. (cond_store_replacement): Likewise. (cond_if_else_store_replacement_1): Likewise. (hoist_adjacent_loads): Likewise. --- gcc/tree-ssa-phiopt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 76f4e7ec843..02e26f974a5 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -419,6 +419,8 @@ replace_phi_edge_with_variable (basic_block cond_block, gsi = gsi_last_bb (cond_block); gsi_remove (&gsi, true); + statistics_counter_event (cfun, "Replace PHI with variable", 1); + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "COND_EXPR in block %d and PHI in block %d converted to straightline code.\n", @@ -618,6 +620,9 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi, /* Remove the original PHI stmt. */ gsi = gsi_for_stmt (phi); gsi_remove (&gsi, true); + + statistics_counter_event (cfun, "factored out cast", 1); + return newphi; } @@ -893,6 +898,11 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, replace_phi_edge_with_variable (cond_bb, e1, phi, result); + /* Add Statistic here even though replace_phi_edge_with_variable already + does it as we want to be able to count when match-simplify happens vs + the others. */ + statistics_counter_event (cfun, "match-simplify PHI replacement", 1); + /* Note that we optimized this PHI. */ return true; } @@ -1196,6 +1206,8 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, } else { + statistics_counter_event (cfun, "Replace PHI with variable/value_replacement", 1); + /* Replace the PHI arguments with arg. */ SET_PHI_ARG_DEF (phi, e0->dest_idx, arg); SET_PHI_ARG_DEF (phi, e1->dest_idx, arg); @@ -2320,6 +2332,7 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb, gimple_stmt_iterator psi = gsi_for_stmt (phi); remove_phi_node (&psi, true); + statistics_counter_event (cfun, "spaceship replacement", 1); return true; } @@ -2982,6 +2995,7 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, fprintf (dump_file, "\nInserted a new PHI statement in joint block:\n"); print_gimple_stmt (dump_file, new_stmt, 0, TDF_VOPS|TDF_MEMSYMS); } + statistics_counter_event (cfun, "conditional store replacement", 1); return true; } @@ -3056,6 +3070,8 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb, else gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT); + statistics_counter_event (cfun, "if-then-else store replacement", 1); + return true; } @@ -3469,6 +3485,7 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1, gsi_move_to_bb_end (&gsi2, bb0); gsi2 = gsi_for_stmt (def2); gsi_move_to_bb_end (&gsi2, bb0); + statistics_counter_event (cfun, "hoisted loads", 1); if (dump_file && (dump_flags & TDF_DETAILS)) {