From 0d55d24aa4e47c40f74e0281d023089cfaafcf74 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Thu, 6 May 2021 14:05:06 +0200
Subject: [PATCH 16/35] [Backport] phiopt: Use gphi *phi instead of gimple *phi
 some more

Reference: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=cfd65e8d5299a7cf7d2ecd92b0e24ea4cfb697d9

Various functions in phiopt are also called with a gphi * but use
gimple * argument for it.

2021-05-06  Jakub Jelinek  <jakub@redhat.com>

	* tree-ssa-phiopt.c (value_replacement, minmax_replacement,
	abs_replacement, xor_replacement,
	cond_removal_in_popcount_clz_ctz_pattern,
	replace_phi_edge_with_variable): Change type of phi argument from
	gimple * to gphi *.
---
 gcc/tree-ssa-phiopt.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 51a2d3684..045a7b1b8 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -59,21 +59,21 @@ static bool match_simplify_replacement (basic_block, basic_block,
 static gphi *factor_out_conditional_conversion (edge, edge, gphi *, tree, tree,
 						gimple *);
 static int value_replacement (basic_block, basic_block,
-			      edge, edge, gimple *, tree, tree);
+			      edge, edge, gphi *, tree, tree);
 static bool minmax_replacement (basic_block, basic_block,
-				edge, edge, gimple *, tree, tree);
+				edge, edge, gphi *, tree, tree);
 static bool abs_replacement (basic_block, basic_block,
-			     edge, edge, gimple *, tree, tree);
+			     edge, edge, gphi *, tree, tree);
 static bool spaceship_replacement (basic_block, basic_block,
 				   edge, edge, gphi *, tree, tree);
 static bool cond_removal_in_popcount_clz_ctz_pattern (basic_block, basic_block,
-						      edge, edge, gimple *,
+						      edge, edge, gphi *,
 						      tree, tree);
 static bool cond_store_replacement (basic_block, basic_block, edge, edge,
 				    hash_set<tree> *);
 static bool cond_if_else_store_replacement (basic_block, basic_block, basic_block);
 static hash_set<tree> * get_non_trapping ();
-static void replace_phi_edge_with_variable (basic_block, edge, gimple *, tree);
+static void replace_phi_edge_with_variable (basic_block, edge, gphi *, tree);
 static void hoist_adjacent_loads (basic_block, basic_block,
 				  basic_block, basic_block);
 static bool do_phiopt_pattern (basic_block, basic_block, basic_block);
@@ -389,7 +389,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 
 static void
 replace_phi_edge_with_variable (basic_block cond_block,
-				edge e, gimple *phi, tree new_tree)
+				edge e, gphi *phi, tree new_tree)
 {
   basic_block bb = gimple_bb (phi);
   basic_block block_to_remove;
@@ -1129,8 +1129,7 @@ absorbing_element_p (tree_code code, tree arg, bool right, tree rval)
 
 static int
 value_replacement (basic_block cond_bb, basic_block middle_bb,
-		   edge e0, edge e1, gimple *phi,
-		   tree arg0, tree arg1)
+		   edge e0, edge e1, gphi *phi, tree arg0, tree arg1)
 {
   gimple_stmt_iterator gsi;
   gimple *cond;
@@ -1438,8 +1437,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
 
 static bool
 minmax_replacement (basic_block cond_bb, basic_block middle_bb,
-		    edge e0, edge e1, gimple *phi,
-		    tree arg0, tree arg1)
+		    edge e0, edge e1, gphi *phi, tree arg0, tree arg1)
 {
   tree result, type, rhs;
   gcond *cond;
@@ -2240,7 +2238,7 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
 static bool
 cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
 					  basic_block middle_bb,
-					  edge e1, edge e2, gimple *phi,
+					  edge e1, edge e2, gphi *phi,
 					  tree arg0, tree arg1)
 {
   gimple *cond;
@@ -2398,7 +2396,7 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
 static bool
 abs_replacement (basic_block cond_bb, basic_block middle_bb,
 		 edge e0 ATTRIBUTE_UNUSED, edge e1,
-		 gimple *phi, tree arg0, tree arg1)
+		 gphi *phi, tree arg0, tree arg1)
 {
   tree result;
   gassign *new_stmt;
-- 
2.27.0.windows.1