This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Don't compare TYPE_MAIN_VARIANTS in middle-end


Hi,

as http://gcc.gnu.org/ml/gcc-patches/2009-08/msg00962.html showed the 
vectorizer tries to rely on comparing TYPE_MAIN_VARIANT to establish type 
similarity (in the sense of needing no conversions).  That's too strong, 
the right thing is using types_compatible_p().  While grepping for 
TYPE_MAIN_VARIANT I saw some other uses also comparing for pointer 
equality that I also fixed.  I left alone some of those compares that 
dealt with varargs.

This fixes the regression in polyhedron I introduced earlier today (and 
will introduce back a regression for Tobias due to unlucky vectorizer cost 
model).  For me at least induct.f90 goes from 23 seconds to 13 seconds.

Regstrapped on x86_64-linux with Ada.  No regressions.  Okay for trunk?


Ciao,
Michael.
-- 
	* gimplify.c (goa_lhs_expr_p): Use types_compatible_p instead
	of comparing TYPE_MAIN_VARIANT for equality.
	* omp-low.c (optimize_omp_library_calls): Ditto.
	* tree-vect-patterns.c (vect_recog_dot_prod_pattern,
	vect_recog_widen_mult_pattern, vect_recog_widen_sum_pattern): Ditto.
	* tree-vect-loop.c (vect_is_simple_reduction): Ditto.

Index: gimplify.c
===================================================================
--- gimplify.c	(revision 150933)
+++ gimplify.c	(working copy)
@@ -6155,8 +6155,8 @@ goa_lhs_expr_p (tree expr, tree addr)
   while ((CONVERT_EXPR_P (expr)
           || TREE_CODE (expr) == NON_LVALUE_EXPR)
          && TREE_OPERAND (expr, 0) != error_mark_node
-         && (TYPE_MAIN_VARIANT (TREE_TYPE (expr))
-             == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (expr, 0)))))
+         && types_compatible_p (TREE_TYPE (expr),
+				TREE_TYPE (TREE_OPERAND (expr, 0))))
     expr = TREE_OPERAND (expr, 0);
 
   if (TREE_CODE (expr) == INDIRECT_REF)
@@ -6166,8 +6166,7 @@ goa_lhs_expr_p (tree expr, tree addr)
 	     && (CONVERT_EXPR_P (expr)
 		 || TREE_CODE (expr) == NON_LVALUE_EXPR)
 	     && TREE_CODE (expr) == TREE_CODE (addr)
-	     && TYPE_MAIN_VARIANT (TREE_TYPE (expr))
-		== TYPE_MAIN_VARIANT (TREE_TYPE (addr)))
+	     && types_compatible_p (TREE_TYPE (expr), TREE_TYPE (addr)))
 	{
 	  expr = TREE_OPERAND (expr, 0);
 	  addr = TREE_OPERAND (addr, 0);
Index: omp-low.c
===================================================================
--- omp-low.c	(revision 150933)
+++ omp-low.c	(working copy)
@@ -3316,8 +3316,8 @@ optimize_omp_library_calls (gimple entry
 	      continue;
 
 	    if (TREE_CODE (TREE_TYPE (decl)) != FUNCTION_TYPE
-		|| TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl)))
-		   != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (built_in))))
+		|| !types_compatible_p (TREE_TYPE (TREE_TYPE (decl)),
+					TREE_TYPE (TREE_TYPE (built_in))))
 	      continue;
 
 	    gimple_call_set_fndecl (call, built_in);
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c	(revision 150933)
+++ tree-vect-patterns.c	(working copy)
@@ -233,8 +233,8 @@ vect_recog_dot_prod_pattern (gimple last
         return NULL;
       oprnd0 = gimple_assign_rhs1 (last_stmt);
       oprnd1 = gimple_assign_rhs2 (last_stmt);
-      if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0)) != TYPE_MAIN_VARIANT (type)
-          || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1)) != TYPE_MAIN_VARIANT (type))
+      if (!types_compatible_p (TREE_TYPE (oprnd0), type)
+	  || !types_compatible_p (TREE_TYPE (oprnd1), type))
         return NULL;
       stmt = last_stmt;
 
@@ -285,10 +285,8 @@ vect_recog_dot_prod_pattern (gimple last
 
       oprnd0 = gimple_assign_rhs1 (stmt);
       oprnd1 = gimple_assign_rhs2 (stmt);
-      if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0)) 
-				!= TYPE_MAIN_VARIANT (prod_type)
-          || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1)) 
-				!= TYPE_MAIN_VARIANT (prod_type))
+      if (!types_compatible_p (TREE_TYPE (oprnd0), prod_type)
+          || !types_compatible_p (TREE_TYPE (oprnd1), prod_type))
         return NULL;
       if (!widened_name_p (oprnd0, stmt, &half_type0, &def_stmt))
         return NULL;
@@ -296,7 +294,7 @@ vect_recog_dot_prod_pattern (gimple last
       if (!widened_name_p (oprnd1, stmt, &half_type1, &def_stmt))
         return NULL;
       oprnd01 = gimple_assign_rhs1 (def_stmt);
-      if (TYPE_MAIN_VARIANT (half_type0) != TYPE_MAIN_VARIANT (half_type1))
+      if (!types_compatible_p (half_type0, half_type1))
         return NULL;
       if (TYPE_PRECISION (prod_type) != TYPE_PRECISION (half_type0) * 2)
 	return NULL;
@@ -384,8 +382,8 @@ vect_recog_widen_mult_pattern (gimple la
 
   oprnd0 = gimple_assign_rhs1 (last_stmt);
   oprnd1 = gimple_assign_rhs2 (last_stmt);
-  if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0)) != TYPE_MAIN_VARIANT (type)
-      || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1)) != TYPE_MAIN_VARIANT (type))
+  if (!types_compatible_p (TREE_TYPE (oprnd0), type)
+      || !types_compatible_p (TREE_TYPE (oprnd1), type))
     return NULL;
 
   /* Check argument 0 */
@@ -398,7 +396,7 @@ vect_recog_widen_mult_pattern (gimple la
     return NULL;
   oprnd1 = gimple_assign_rhs1 (def_stmt1);
 
-  if (TYPE_MAIN_VARIANT (half_type0) != TYPE_MAIN_VARIANT (half_type1))
+  if (!types_compatible_p (half_type0, half_type1))
     return NULL;
 
   /* Pattern detected.  */
@@ -602,8 +600,8 @@ vect_recog_widen_sum_pattern (gimple las
 
   oprnd0 = gimple_assign_rhs1 (last_stmt);
   oprnd1 = gimple_assign_rhs2 (last_stmt);
-  if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0)) != TYPE_MAIN_VARIANT (type)
-      || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1)) != TYPE_MAIN_VARIANT (type))
+  if (!types_compatible_p (TREE_TYPE (oprnd0), type)
+      || !types_compatible_p (TREE_TYPE (oprnd1), type))
     return NULL;
 
   /* So far so good. Since last_stmt was detected as a (summation) reduction,
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 150933)
+++ tree-vect-loop.c	(working copy)
@@ -1739,13 +1739,13 @@ vect_is_simple_reduction (loop_vec_info
 
   type = TREE_TYPE (gimple_assign_lhs (def_stmt));
   if ((TREE_CODE (op1) == SSA_NAME
-       && TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (op1)))
+       && !types_compatible_p (type,TREE_TYPE (op1)))
       || (TREE_CODE (op2) == SSA_NAME
-          && TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (op2)))
+          && !types_compatible_p (type, TREE_TYPE (op2)))
       || (op3 && TREE_CODE (op3) == SSA_NAME
-          && TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (op3)))
+          && !types_compatible_p (type, TREE_TYPE (op3)))
       || (op4 && TREE_CODE (op4) == SSA_NAME
-          && TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (op4))))
+          && !types_compatible_p (type, TREE_TYPE (op4))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]