[PATCH 2/3] Remove last gimple_expr_type uses

Richard Biener rguenther@suse.de
Fri Jul 16 13:02:32 GMT 2021


This removes the last uses of gimple_expr_type.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

2021-07-16  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (vn_reference_eq): Handle NULL vr->type.
	(ao_ref_init_from_vn_reference): Likewise.
	(vn_reference_lookup_call): Do not set vr->type to random
	values.
	* tree-vect-generic.c (expand_vector_piecewise): Pass in
	whether we expanded parallel.
	(expand_vector_parallel): Adjust.
	(expand_vector_addition): Likewise.
	(expand_vector_comparison): Likewise.
	(expand_vector_operation): Likewise.
	(expand_vector_scalar_condition): Likewise.
	(expand_vector_conversion): Likewise.
---
 gcc/tree-ssa-sccvn.c    | 27 +++++++++++++++++++--------
 gcc/tree-vect-generic.c | 25 ++++++++++++-------------
 2 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 7900df946f4..b8882b64fe3 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -764,14 +764,18 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2)
   if (vr1->operands == vr2->operands)
     return true;
 
-  if (COMPLETE_TYPE_P (vr1->type) != COMPLETE_TYPE_P (vr2->type)
-      || (COMPLETE_TYPE_P (vr1->type)
-	  && !expressions_equal_p (TYPE_SIZE (vr1->type),
-				   TYPE_SIZE (vr2->type))))
+  if (!vr1->type || !vr2->type)
+    {
+      if (vr1->type != vr2->type)
+	return false;
+    }
+  else if (COMPLETE_TYPE_P (vr1->type) != COMPLETE_TYPE_P (vr2->type)
+	   || (COMPLETE_TYPE_P (vr1->type)
+	       && !expressions_equal_p (TYPE_SIZE (vr1->type),
+					TYPE_SIZE (vr2->type))))
     return false;
-
-  if (INTEGRAL_TYPE_P (vr1->type)
-      && INTEGRAL_TYPE_P (vr2->type))
+  else if (INTEGRAL_TYPE_P (vr1->type)
+	   && INTEGRAL_TYPE_P (vr2->type))
     {
       if (TYPE_PRECISION (vr1->type) != TYPE_PRECISION (vr2->type))
 	return false;
@@ -1049,6 +1053,10 @@ ao_ref_init_from_vn_reference (ao_ref *ref,
   poly_offset_int size = -1;
   tree size_tree = NULL_TREE;
 
+  /* We don't handle calls.  */
+  if (!type)
+    return false;
+
   machine_mode mode = TYPE_MODE (type);
   if (mode == BLKmode)
     size_tree = TYPE_SIZE (type);
@@ -3671,7 +3679,10 @@ vn_reference_lookup_call (gcall *call, vn_reference_t *vnresult,
 
   vr->vuse = vuse ? SSA_VAL (vuse) : NULL_TREE;
   vr->operands = valueize_shared_reference_ops_from_call (call);
-  vr->type = gimple_expr_type (call);
+  tree lhs = gimple_call_lhs (call);
+  /* For non-SSA return values the referece ops contain the LHS.  */
+  vr->type = ((lhs && TREE_CODE (lhs) == SSA_NAME)
+	      ? TREE_TYPE (lhs) : NULL_TREE);
   vr->punned = false;
   vr->set = 0;
   vr->base_set = 0;
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index a1257db82a6..2e00b3ed3ca 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -307,7 +307,7 @@ static tree
 expand_vector_piecewise (gimple_stmt_iterator *gsi, elem_op_func f,
 			 tree type, tree inner_type,
 			 tree a, tree b, enum tree_code code,
-			 tree ret_type = NULL_TREE)
+			 bool parallel_p, tree ret_type = NULL_TREE)
 {
   vec<constructor_elt, va_gc> *v;
   tree part_width = TYPE_SIZE (inner_type);
@@ -317,8 +317,7 @@ expand_vector_piecewise (gimple_stmt_iterator *gsi, elem_op_func f,
   int i;
   location_t loc = gimple_location (gsi_stmt (*gsi));
 
-  if (ret_type
-      || types_compatible_p (gimple_expr_type (gsi_stmt (*gsi)), type))
+  if (ret_type || !parallel_p)
     warning_at (loc, OPT_Wvector_operation_performance,
 		"vector operation will be expanded piecewise");
   else
@@ -364,13 +363,13 @@ expand_vector_parallel (gimple_stmt_iterator *gsi, elem_op_func f, tree type,
   if (TYPE_MODE (TREE_TYPE (type)) == word_mode)
      return expand_vector_piecewise (gsi, f,
 				     type, TREE_TYPE (type),
-				     a, b, code);
+				     a, b, code, true);
   else if (n_words > 1)
     {
       tree word_type = build_word_mode_vector_type (n_words);
       result = expand_vector_piecewise (gsi, f,
 				        word_type, TREE_TYPE (word_type),
-					a, b, code);
+					a, b, code, true);
       result = force_gimple_operand_gsi (gsi, result, true, NULL, true,
                                          GSI_SAME_STMT);
     }
@@ -410,7 +409,7 @@ expand_vector_addition (gimple_stmt_iterator *gsi,
   else
     return expand_vector_piecewise (gsi, f,
 				    type, TREE_TYPE (type),
-				    a, b, code);
+				    a, b, code, false);
 }
 
 static bool
@@ -501,7 +500,7 @@ expand_vector_comparison (gimple_stmt_iterator *gsi, tree type, tree op0,
       else
 	t = expand_vector_piecewise (gsi, do_compare, type,
 				     TREE_TYPE (TREE_TYPE (op0)), op0, op1,
-				     code);
+				     code, false);
     }
   else
     t = NULL_TREE;
@@ -1248,11 +1247,11 @@ expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type
   if (TREE_CODE_CLASS (code) == tcc_unary)
     return expand_vector_piecewise (gsi, do_unop, type, compute_type,
 				    gimple_assign_rhs1 (assign),
-				    NULL_TREE, code);
+				    NULL_TREE, code, false);
   else
     return expand_vector_piecewise (gsi, do_binop, type, compute_type,
 				    gimple_assign_rhs1 (assign),
-				    gimple_assign_rhs2 (assign), code);
+				    gimple_assign_rhs2 (assign), code, false);
 }
 
 /* Try to optimize
@@ -1762,7 +1761,7 @@ expand_vector_scalar_condition (gimple_stmt_iterator *gsi)
 				      COND_EXPR);
   else
     new_rhs = expand_vector_piecewise (gsi, do_cond, type, compute_type,
-				       rhs2, rhs3, COND_EXPR);
+				       rhs2, rhs3, COND_EXPR, false);
   if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (new_rhs)))
     new_rhs = gimplify_build1 (gsi, VIEW_CONVERT_EXPR, TREE_TYPE (lhs),
 			       new_rhs);
@@ -1885,7 +1884,7 @@ expand_vector_conversion (gimple_stmt_iterator *gsi)
 		{
 		  new_rhs = expand_vector_piecewise (gsi, do_vec_conversion,
 						     ret_type, arg1_type, arg,
-						     NULL_TREE, code1);
+						     NULL_TREE, code1, false);
 		  g = gimple_build_assign (lhs, new_rhs);
 		  gsi_replace (gsi, g, false);
 		  return;
@@ -1953,7 +1952,7 @@ expand_vector_conversion (gimple_stmt_iterator *gsi)
 						   do_vec_narrow_conversion,
 						   arg_type, dcompute_type,
 						   arg, NULL_TREE, code1,
-						   ret_type);
+						   false, ret_type);
 	      g = gimple_build_assign (lhs, new_rhs);
 	      gsi_replace (gsi, g, false);
 	      return;
@@ -2065,7 +2064,7 @@ expand_vector_conversion (gimple_stmt_iterator *gsi)
 
   new_rhs = expand_vector_piecewise (gsi, do_vec_conversion, arg_type,
 				     TREE_TYPE (arg_type), arg,
-				     NULL_TREE, code, ret_type);
+				     NULL_TREE, code, false, ret_type);
   g = gimple_build_assign (lhs, new_rhs);
   gsi_replace (gsi, g, false);
 }
-- 
2.26.2



More information about the Gcc-patches mailing list