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]

Re: [patch] fix PR34413: ltrans-7.f90 fails on amd64-linux


On Dec 20, 2007 11:14 PM, David Daney <ddaney@avtrex.com> wrote:
> David Daney wrote:
> > Sebastian Pop wrote:
> >
> >> Hi,
> >> the attached patch fixes the loop interchange for this important
> >> testcase.  The original patch that I sent as feedback to the PR
> >> http://gcc.gnu.org/PR34413 fails for two cases in the vectorizer
> >> vect-{104,105}.c where the type of the chrec_a is a pointer type and
> >> the difference expected chrec_b to be of size_type in that case.  This
> >> patch uses a larger integer type, long_integer_type_node instead of
> >> integer_type_node, such that on 64 bit machines pointer types can fit
> >> in.  The patch bootstrapped and passed testsuite fixing ltrans-7.f90
> >> on an amd64-linux.  I will commit the patch to trunk.
> >>
> >> Sebastian
> >>
> >> ------------------------------------------------------------------------
> >>
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >>
> >> 2007-12-19  Sebastian Pop  <sebastian.pop@amd.com>
> >>
> >>      PR tree-optimization/34413
> >>      * tree-data-ref.c (affine_fn_op, analyze_ziv_subscript,
> >>      analyze_siv_subscript_cst_affine, analyze_miv_subscript,
> >>      omega_setup_subscript): Use long_integer_type_node instead of
> >>      integer_type_node.
> >>
> >>
> >>
> > This causes an ICE on certain java code.
> > long_integer_type_node is NULL.  I am not sure where it is supposed to
> > be initialized.
> >
> >
> For java *type_node is initialize in gcc/java/decl.c in
> java_init_decl_processing ().  Java does not initialize
> long_integer_type_node thus the ICE because your patch uses
> long_integer_type_node.
>
> For the time being I am going to revert this patch in my local tree.  My
> testcase is a 1000 class 600,000 line program.  If a reduced test case
> is needed I may be able to generate one in a couple of days.
>

I'm testing another patch for using the front-end specific signed types
from a type.  Attached is the patch that I'm bootstrapping on amd64-linux.

Sorry for the fails,
Sebastian
2007-12-20  Sebastian Pop  <sebastian.pop@amd.com>

	* tree-data-ref.c (signed_type_for_types): New.
	(affine_fn_op): Use signed_type_for_types and signed_type_for instead
	of long_integer_type_node.
	(analyze_ziv_subscript): Same.
	(analyze_siv_subscript_cst_affine): Same.
	(analyze_miv_subscript): Same.
	(omega_setup_subscript): Same.

email:sebpop@gmail.com
branch:trunk
revision:HEAD
configure:
make:
check:

Index: tree-data-ref.c
===================================================================
--- tree-data-ref.c	(revision 131097)
+++ tree-data-ref.c	(working copy)
@@ -935,6 +935,18 @@ affine_function_zero_p (affine_fn fn)
 	  && affine_function_constant_p (fn));
 }
 
+/* Returns a signed integer type with the largest precision from TA
+   and TB.  */
+
+static tree
+signed_type_for_types (tree ta, tree tb)
+{
+  if (TYPE_PRECISION (ta) > TYPE_PRECISION (tb))
+    return signed_type_for (ta);
+  else
+    return signed_type_for (tb);
+}
+
 /* Applies operation OP on affine functions FNA and FNB, and returns the
    result.  */
 
@@ -958,18 +970,23 @@ affine_fn_op (enum tree_code op, affine_
 
   ret = VEC_alloc (tree, heap, m);
   for (i = 0; i < n; i++)
-    VEC_quick_push (tree, ret,
-		    fold_build2 (op, long_integer_type_node,
-				 VEC_index (tree, fna, i), 
-				 VEC_index (tree, fnb, i)));
+    {
+      tree type = signed_type_for_types (TREE_TYPE (VEC_index (tree, fna, i)),
+					 TREE_TYPE (VEC_index (tree, fnb, i)));
+
+      VEC_quick_push (tree, ret,
+		      fold_build2 (op, type,
+				   VEC_index (tree, fna, i), 
+				   VEC_index (tree, fnb, i)));
+    }
 
   for (; VEC_iterate (tree, fna, i, coef); i++)
     VEC_quick_push (tree, ret,
-		    fold_build2 (op, long_integer_type_node,
+		    fold_build2 (op, signed_type_for (TREE_TYPE (coef)),
 				 coef, integer_zero_node));
   for (; VEC_iterate (tree, fnb, i, coef); i++)
     VEC_quick_push (tree, ret,
-		    fold_build2 (op, long_integer_type_node,
+		    fold_build2 (op, signed_type_for (TREE_TYPE (coef)),
 				 integer_zero_node, coef));
 
   return ret;
@@ -1484,15 +1501,16 @@ analyze_ziv_subscript (tree chrec_a, 
 		       conflict_function **overlaps_b, 
 		       tree *last_conflicts)
 {
-  tree difference;
+  tree type, difference;
   dependence_stats.num_ziv++;
   
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "(analyze_ziv_subscript \n");
-  
-  chrec_a = chrec_convert (long_integer_type_node, chrec_a, NULL_TREE);
-  chrec_b = chrec_convert (long_integer_type_node, chrec_b, NULL_TREE);
-  difference = chrec_fold_minus (long_integer_type_node, chrec_a, chrec_b);
+
+  type = signed_type_for_types (TREE_TYPE (chrec_a), TREE_TYPE (chrec_b));
+  chrec_a = chrec_convert (type, chrec_a, NULL_TREE);
+  chrec_b = chrec_convert (type, chrec_b, NULL_TREE);
+  difference = chrec_fold_minus (type, chrec_a, chrec_b);
   
   switch (TREE_CODE (difference))
     {
@@ -1618,12 +1636,12 @@ analyze_siv_subscript_cst_affine (tree c
 				  tree *last_conflicts)
 {
   bool value0, value1, value2;
-  tree difference, tmp;
+  tree type, difference, tmp;
 
-  chrec_a = chrec_convert (long_integer_type_node, chrec_a, NULL_TREE);
-  chrec_b = chrec_convert (long_integer_type_node, chrec_b, NULL_TREE);
-  difference = chrec_fold_minus 
-    (long_integer_type_node, initial_condition (chrec_b), chrec_a);
+  type = signed_type_for_types (TREE_TYPE (chrec_a), TREE_TYPE (chrec_b));
+  chrec_a = chrec_convert (type, chrec_a, NULL_TREE);
+  chrec_b = chrec_convert (type, chrec_b, NULL_TREE);
+  difference = chrec_fold_minus (type, initial_condition (chrec_b), chrec_a);
   
   if (!chrec_is_positive (initial_condition (difference), &value0))
     {
@@ -1666,10 +1684,8 @@ analyze_siv_subscript_cst_affine (tree c
 		      struct loop *loop = get_chrec_loop (chrec_b);
 
 		      *overlaps_a = conflict_fn (1, affine_fn_cst (integer_zero_node));
-		      tmp = fold_build2 (EXACT_DIV_EXPR, long_integer_type_node,
-					 fold_build1 (ABS_EXPR,
-						      long_integer_type_node,
-						      difference),
+		      tmp = fold_build2 (EXACT_DIV_EXPR, type,
+					 fold_build1 (ABS_EXPR, type, difference),
 					 CHREC_RIGHT (chrec_b));
 		      *overlaps_b = conflict_fn (1, affine_fn_cst (tmp));
 		      *last_conflicts = integer_one_node;
@@ -1748,8 +1764,7 @@ analyze_siv_subscript_cst_affine (tree c
 		      struct loop *loop = get_chrec_loop (chrec_b);
 
 		      *overlaps_a = conflict_fn (1, affine_fn_cst (integer_zero_node));
-		      tmp = fold_build2 (EXACT_DIV_EXPR,
-					 long_integer_type_node, difference, 
+		      tmp = fold_build2 (EXACT_DIV_EXPR, type, difference,
 					 CHREC_RIGHT (chrec_b));
 		      *overlaps_b = conflict_fn (1, affine_fn_cst (tmp));
 		      *last_conflicts = integer_one_node;
@@ -2445,14 +2460,16 @@ analyze_miv_subscript (tree chrec_a, 
      variables.  In the MIV case we have to solve a Diophantine
      equation with 2*n variables (if the subscript uses n IVs).
   */
-  tree difference;
+  tree type, difference;
+
   dependence_stats.num_miv++;
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "(analyze_miv_subscript \n");
 
-  chrec_a = chrec_convert (long_integer_type_node, chrec_a, NULL_TREE);
-  chrec_b = chrec_convert (long_integer_type_node, chrec_b, NULL_TREE);
-  difference = chrec_fold_minus (long_integer_type_node, chrec_a, chrec_b);
+  type = signed_type_for_types (TREE_TYPE (chrec_a), TREE_TYPE (chrec_b));
+  chrec_a = chrec_convert (type, chrec_a, NULL_TREE);
+  chrec_b = chrec_convert (type, chrec_b, NULL_TREE);
+  difference = chrec_fold_minus (type, chrec_a, chrec_b);
   
   if (eq_evolutions_p (chrec_a, chrec_b))
     {
@@ -3400,9 +3417,11 @@ omega_setup_subscript (tree access_fun_a
 		       omega_pb pb, bool *maybe_dependent)
 {
   int eq;
-  tree fun_a = chrec_convert (long_integer_type_node, access_fun_a, NULL_TREE);
-  tree fun_b = chrec_convert (long_integer_type_node, access_fun_b, NULL_TREE);
-  tree difference = chrec_fold_minus (long_integer_type_node, fun_a, fun_b);
+  tree type = signed_type_for_types (TREE_TYPE (access_fun_a),
+				     TREE_TYPE (access_fun_b));
+  tree fun_a = chrec_convert (type, access_fun_a, NULL_TREE);
+  tree fun_b = chrec_convert (type, access_fun_b, NULL_TREE);
+  tree difference = chrec_fold_minus (type, fun_a, fun_b);
 
   /* When the fun_a - fun_b is not constant, the dependence is not
      captured by the classic distance vector representation.  */
@@ -3417,8 +3436,7 @@ omega_setup_subscript (tree access_fun_a
       return true;
     }
 
-  fun_b = chrec_fold_multiply (long_integer_type_node, fun_b, 
-			       integer_minus_one_node);
+  fun_b = chrec_fold_multiply (type, fun_b, integer_minus_one_node);
 
   eq = omega_add_zero_eq (pb, omega_black);
   if (!init_omega_eq_with_af (pb, eq, DDR_NB_LOOPS (ddr), fun_a, ddr)

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