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]

[lno] Clean duplicated functions


Hi, 

this patch cleans the vestiges of the old number of iterations
functions.  The conditions elimination pass is disabled for the moment
until I get it working with number_of_iterations_cond.  Bootstrapped
on i686-pc-linux-gnu.

Sebastian

Index: ChangeLog.lno
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ChangeLog.lno,v
retrieving revision 1.1.2.194
diff -d -u -p -r1.1.2.194 ChangeLog.lno
--- ChangeLog.lno	17 Jun 2004 18:25:11 -0000	1.1.2.194
+++ ChangeLog.lno	18 Jun 2004 20:40:24 -0000
@@ -1,3 +1,21 @@
+2004-06-18  Sebastian Pop  <pop@cri.ensmp.fr>
+
+	* Makefile.in (OBJS-common): Remove tree-elim-check.o.
+	* tree-scalar-evolution.c (first_iteration_non_satisfying_noev_noev, 
+	first_iteration_non_satisfying_noev_ev, 
+	first_iteration_non_satisfying_ev_noev, 
+	first_iteration_non_satisfying_ev_ev, 
+	first_iteration_non_satisfying_1, 
+	first_iteration_non_satisfying): Removed.
+	(number_of_iterations_in_loop): Clean up.
+	* tree-scalar-evolution.h (first_iteration_non_satisfying): Removed.
+	* tree-ssa-loop-ivopts.c (zero_p): Compare tree pointer
+	against NULL_TREE.
+	* tree-ssa-loop.c (tree_ssa_loop_test): Return when loops
+	structure is not available.
+	(tree_elim_checks): Disabled for the moment.  Don't call
+	eliminate_redundant_checks.
+
 2004-06-17  Andrew MacLeod  <amacleod@redhat.com>
 
 	* tree-cfg.c (tree_make_forwarder_block):  Use SET_PHI_RESULT.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.158.2.33
diff -d -u -p -r1.903.2.158.2.33 Makefile.in
--- Makefile.in	16 Jun 2004 20:54:52 -0000	1.903.2.158.2.33
+++ Makefile.in	18 Jun 2004 20:40:24 -0000
@@ -886,7 +886,6 @@ C_OBJS = c-parse.o c-lang.o stub-objc.o 
 
 OBJS-common = \
  tree-chrec.o tree-scalar-evolution.o tree-data-ref.o tree-fold-const.o    \
- tree-elim-check.o                                                         \
  tree-loop-linear.o lambda-mat.o lambda-trans.o lambda-code.o              \
  tree-cfg.o tree-dfa.o tree-eh.o tree-ssa.o tree-optimize.o tree-gimple.o  \
  tree-alias-type.o gimplify.o tree-pretty-print.o tree-into-ssa.o          \
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.c,v
retrieving revision 1.1.2.57
diff -d -u -p -r1.1.2.57 tree-scalar-evolution.c
--- tree-scalar-evolution.c	16 Jun 2004 20:54:52 -0000	1.1.2.57
+++ tree-scalar-evolution.c	18 Jun 2004 20:40:24 -0000
@@ -907,307 +907,6 @@ add_to_evolution (unsigned loop_nb, 
   return res;
 }
 
-
-
-/* This section deals with the approximation of the number of
-   iterations a loop will run.  */
-
-/* Helper function for the case when both evolution functions don't
-   have an evolution in the considered loop.  */
-
-static tree 
-first_iteration_non_satisfying_noev_noev (enum tree_code code, 
-					  unsigned loop_nb ATTRIBUTE_UNUSED, 
-					  tree chrec0, 
-					  tree chrec1)
-{
-  bool val = false;
-  tree init0 = initial_condition (chrec0);
-  tree init1 = initial_condition (chrec1);
-  
-  if (TREE_CODE (init0) != INTEGER_CST
-      || TREE_CODE (init1) != INTEGER_CST)
-    return chrec_top;
-
-  switch (code)
-    {
-    case LE_EXPR:
-      if (!tree_is_gt (init0, init1, &val))
-	return chrec_top;
-      break;
-
-    case LT_EXPR:
-      if (!tree_is_ge (init0, init1, &val))
-	return chrec_top;
-      break;
-
-    case EQ_EXPR:
-      if (!tree_is_eq (init0, init1, &val))
-	return chrec_top;
-      break;
-
-    case NE_EXPR:
-      if (!tree_is_ne (init0, init1, &val))
-	return chrec_top;
-      break;
-
-    default:
-      return chrec_top;
-    }
-
-  if (val)
-    return integer_zero_node;
-  else if (evolution_function_is_constant_p (chrec0)
-	   && evolution_function_is_constant_p (chrec1))
-    return chrec_bot;
-  else
-    return chrec_top;
-}
-
-/* Helper function for the case when CHREC0 has no evolution and
-   CHREC1 has an evolution in the considered loop.  */
-
-static tree 
-first_iteration_non_satisfying_noev_ev (enum tree_code code, 
-					unsigned loop_nb, 
-					tree chrec0, 
-					tree chrec1)
-{
-  bool val = false;
-  tree type1 = chrec_type (chrec1);
-  /*  tree tmax = TYPE_MAX_VALUE (type1); */
-  tree ev_in_this_loop;
-  tree init0, init1, step1;
-  struct tree_niter_desc niter_desc;
-  
-  ev_in_this_loop = hide_evolution_in_other_loops_than_loop (chrec1, loop_nb);
-  if (!evolution_function_is_affine_p (ev_in_this_loop))
-    /* For the moment handle only polynomials of degree 1.  */
-    return chrec_top;
-  
-  init1 = CHREC_LEFT (ev_in_this_loop);
-  step1 = CHREC_RIGHT (ev_in_this_loop);
-  init0 = initial_condition (chrec0);
-  if (!no_evolution_in_loop_p (init0, loop_nb, &val) 
-      || val == false
-      || !no_evolution_in_loop_p (init1, loop_nb, &val) 
-      || val == false
-      || TREE_CODE (step1) != INTEGER_CST)
-    /* For the moment we deal only with INTEGER_CSTs.  */
-    return chrec_top;
-
-  niter_desc.niter = NULL_TREE;
-  number_of_iterations_cond (type1, init0, NULL_TREE, code, init1, step1, 
-			     &niter_desc);
-  if (niter_desc.niter != NULL_TREE
-      && integer_onep (niter_desc.assumptions)
-      && integer_zerop (niter_desc.may_be_zero))
-    return niter_desc.niter;
-  return chrec_top;
-}
-
-/* Helper function for the case when CHREC1 has no evolution and
-   CHREC0 has an evolution in the considered loop.  */
-
-static tree 
-first_iteration_non_satisfying_ev_noev (enum tree_code code, 
-					unsigned loop_nb, 
-					tree chrec0, 
-					tree chrec1)
-{
-  bool val = false;
-  tree type0 = chrec_type (chrec0);
-  /*  tree tmin = TYPE_MIN_VALUE (type0); */
-  tree ev_in_this_loop;
-  tree init0, init1, step0;
-  struct tree_niter_desc niter_desc;
-
-  ev_in_this_loop = hide_evolution_in_other_loops_than_loop (chrec0, loop_nb);
-  if (!evolution_function_is_affine_p (ev_in_this_loop))
-    /* For the moment handle only polynomials of degree 1.  */
-    return chrec_top;
-
-  init0 = CHREC_LEFT (ev_in_this_loop);
-  step0 = CHREC_RIGHT (ev_in_this_loop);
-  init1 = initial_condition (chrec1);
-  if (!no_evolution_in_loop_p (init0, loop_nb, &val) 
-      || val == false
-      || !no_evolution_in_loop_p (init1, loop_nb, &val) 
-      || val == false
-      || TREE_CODE (step0) != INTEGER_CST)
-    /* For the moment we deal only with INTEGER_CSTs.  */
-    return chrec_top;
-
-  niter_desc.niter = NULL_TREE;
-  number_of_iterations_cond (type0, init0, step0, code, init1, NULL_TREE, 
-			     &niter_desc);
-  if (niter_desc.niter != NULL_TREE
-      && integer_onep (niter_desc.assumptions)
-      && integer_zerop (niter_desc.may_be_zero))
-    return niter_desc.niter;
-  return chrec_top;
-}
-
-/* Helper function for the case when both CHREC0 and CHREC1 has an
-   evolution in the considered loop.  */
-
-static tree 
-first_iteration_non_satisfying_ev_ev (enum tree_code code, 
-				      unsigned loop_nb, 
-				      tree chrec0, 
-				      tree chrec1)
-{
-  bool val = false;
-  tree init0, init1, step0, step1;
-  tree type0, type1;
-  struct tree_niter_desc niter_desc;
-
-  if (evolution_function_is_multivariate (chrec0)
-      || evolution_function_is_multivariate (chrec1))
-    /* For the moment, don't handle these quite difficult cases.  */
-    return chrec_top;
-
-  if (!evolution_function_is_affine_p (chrec0)
-      || !evolution_function_is_affine_p (chrec1))
-    /* For the moment handle only polynomials of degree 1.  */
-    return chrec_top;
-
-  init0 = CHREC_LEFT (chrec0);
-  step0 = CHREC_RIGHT (chrec0);
-  init1 = CHREC_LEFT (chrec1);
-  step1 = CHREC_RIGHT (chrec1);
-  if (!no_evolution_in_loop_p (init0, loop_nb, &val) 
-      || val == false
-      || !no_evolution_in_loop_p (init1, loop_nb, &val) 
-      || val == false
-      || TREE_CODE (step0) != INTEGER_CST
-      || TREE_CODE (step1) != INTEGER_CST)
-    /* For the moment, we deal only with INTEGER_CSTs.  */
-    return chrec_top;
-
-  type0 = chrec_type (chrec0);
-  type1 = chrec_type (chrec1);
-  if (type0 != type1)
-    return chrec_top;
-
-  niter_desc.niter = NULL_TREE;
-  number_of_iterations_cond (type0, init0, step0, code, init1, step1, 
-			     &niter_desc);
-  if (niter_desc.niter != NULL_TREE
-      && integer_onep (niter_desc.assumptions)
-      && integer_zerop (niter_desc.may_be_zero))
-    return niter_desc.niter;
-  return chrec_top;
-}
-
-/* Helper function.  */
-
-static tree 
-first_iteration_non_satisfying_1 (enum tree_code code, 
-				  unsigned loop_nb, 
-				  tree chrec0, 
-				  tree chrec1)
-{
-  bool val = false;
-  tree res, other_evs;
-  
-  if (automatically_generated_chrec_p (chrec0)
-      || automatically_generated_chrec_p (chrec1))
-    return chrec_top;
-  
-  if (!no_evolution_in_loop_p (chrec0, loop_nb, &val))
-    return chrec_top;
-  
-  else if (val)
-    {
-      if (!no_evolution_in_loop_p (chrec1, loop_nb, &val))
-	return chrec_top;
-      
-      else if (val)
-	return first_iteration_non_satisfying_noev_noev (code, loop_nb, 
-							chrec0, chrec1);
-      else
-	{
-	  res = first_iteration_non_satisfying_noev_ev (code, loop_nb, 
-							chrec0, chrec1);
-	  if (res == chrec_top)
-	    return res;
-	  
-	  other_evs = hide_evolution_in_loop (chrec1, loop_nb);
-	  other_evs = chrec_fold_minus (chrec_type (other_evs),
-                                                         other_evs, chrec0);
-	  other_evs = chrec_replace_initial_condition 
-	    (other_evs, fold_convert (chrec_type (other_evs), integer_zero_node));
-	}
-    }
-  
-  else
-    {
-      if (!no_evolution_in_loop_p (chrec1, loop_nb, &val))
-	return chrec_top;
-
-      else if (val)
-	{
-	  res = first_iteration_non_satisfying_ev_noev (code, loop_nb, 
-							chrec0, chrec1);
-	  if (res == chrec_top)
-	    return res;
-	  
-	  other_evs = hide_evolution_in_loop (chrec0, loop_nb);
-	  other_evs = chrec_fold_minus (chrec_type (other_evs),
-                                                         other_evs, chrec1);
-	  other_evs = chrec_replace_initial_condition 
-	    (other_evs, fold_convert (chrec_type (other_evs), integer_zero_node));
-	}
-      else
-	return first_iteration_non_satisfying_ev_ev (code, loop_nb, 
-						     chrec0, chrec1);
-    }
-
-  res = chrec_fold_minus (chrec_type (res), res, other_evs);
-  return res;
-}
-
-/* Try to compute the first iteration I of LOOP_NB that does not satisfy
-   CODE: in the context of the computation of the number of iterations:
-   - if (CODE is LE_EXPR) the loop exits when CHREC0 (I) > CHREC1 (I),
-   - if (CODE is LT_EXPR) the loop exits when CHREC0 (I) >= CHREC1 (I),
-   - if (CODE is EQ_EXPR) the loop exits when CHREC0 (I) != CHREC1 (I), 
-   ...
-   
-   The result is one of the following: 
-   - CHREC_TOP when the analyzer cannot determine the property, 
-   - CHREC_BOT when the property is always true, 
-   - an INTEGER_CST tree node, 
-   - a CHREC, 
-   - an expression containing SSA_NAMEs.
-*/
-
-tree 
-first_iteration_non_satisfying (enum tree_code code, 
-				unsigned loop_nb, 
-				tree chrec0, 
-				tree chrec1)
-{
-  switch (code)
-    {
-    case EQ_EXPR:
-    case NE_EXPR:
-    case LT_EXPR:
-    case LE_EXPR:
-      return first_iteration_non_satisfying_1 (code, loop_nb, chrec0, chrec1);
-
-    case GT_EXPR:
-      return first_iteration_non_satisfying_1 (LT_EXPR, loop_nb, 
-					       chrec1, chrec0);
-    case GE_EXPR:
-      return first_iteration_non_satisfying_1 (LE_EXPR, loop_nb, 
-					       chrec1, chrec0);
-    default:
-      return chrec_top;
-    }
-}
-
 /* Helper function.  */
 
 static inline tree
@@ -2485,8 +2184,6 @@ number_of_iterations_in_loop (struct loo
     return res;
   res = chrec_top;
   
-  /* The code in first_iteration_non_satisfying is buggy, so for
-     now play it safe.  */
   if (!loop_exit_edges (loop))
     goto end;
   exit = loop_exit_edge (loop, 0);
@@ -2502,92 +2199,6 @@ number_of_iterations_in_loop (struct loo
   else
     res = chrec_top;
 
-#if 0
-  enum tree_code code;
-  tree cond, test, opnd0, opnd1;
-  tree chrec0, chrec1;
-
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "(number_of_iterations_in_loop \n");
-  
-  cond = get_loop_exit_condition (loop);
-  if (cond == NULL_TREE)
-    return set_nb_iterations_in_loop (loop, chrec_top);
-  
-  test = TREE_OPERAND (cond, 0);
-  exit = loop_exit_edge (loop, 0);
-  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src))
-    return set_nb_iterations_in_loop (loop, chrec_top);
-
-  if (exit->flags & EDGE_TRUE_VALUE)
-    test = invert_truthvalue (test);
-
-  code = TREE_CODE (test);
-  switch (code)
-    {
-    case SSA_NAME:
-      /* "while (opnd0 != 0)".  */
-      code = NE_EXPR;
-      chrec0 = analyze_scalar_evolution (loop, test);
-      chrec1 = integer_zero_node;
-
-      if (chrec0 == chrec_top)
-	/* KEEP_IT_SYMBOLIC.  */
-	chrec0 = test;
-
-      goto end;
-
-    case LT_EXPR:
-    case LE_EXPR:
-    case GT_EXPR:
-    case GE_EXPR:
-    case EQ_EXPR:
-    case NE_EXPR:
-      opnd0 = TREE_OPERAND (test, 0);
-      opnd1 = TREE_OPERAND (test, 1);
-      chrec0 = analyze_scalar_evolution (loop, opnd0);
-      chrec1 = analyze_scalar_evolution (loop, opnd1);
-
-      if (chrec0 == chrec_top)
-	/* KEEP_IT_SYMBOLIC.  */
-	chrec0 = opnd0;
-      
-      if (chrec1 == chrec_top)
-	/* KEEP_IT_SYMBOLIC.  */
-	chrec1 = opnd1;
-
-      goto end;
-      
-    default:
-      return set_nb_iterations_in_loop (loop, chrec_top);
-    }
-
- end:
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    {
-      fprintf (dump_file, "  (loop_nb = %d)\n", loop->num);
-      fprintf (dump_file, "  (loop_while_expr_is_true: ");
-      print_generic_expr (dump_file, test, 0);
-      fprintf (dump_file, ")\n  (chrec0 = ");
-      print_generic_expr (dump_file, chrec0, 0);
-      fprintf (dump_file, ")\n  (chrec1 = ");
-      print_generic_expr (dump_file, chrec1, 0);
-      fprintf (dump_file, ")\n");
-    }
-  
-  if (chrec_contains_undetermined (chrec0)
-      || chrec_contains_undetermined (chrec1))
-    {
-      if (dump_file && (dump_flags & TDF_DETAILS))
-	fprintf (dump_file, "  (nb_iterations cannot be determined))\n");
-      
-      /* Do not update the loop->nb_iterations.  */
-      return chrec_top;
-    }
-
-  res = first_iteration_non_satisfying (code, loop->num, chrec0, chrec1);
-#endif
-
 end:
   return set_nb_iterations_in_loop (loop, res);
 }
Index: tree-scalar-evolution.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.h,v
retrieving revision 1.1.2.13
diff -d -u -p -r1.1.2.13 tree-scalar-evolution.h
--- tree-scalar-evolution.h	11 Jun 2004 02:51:27 -0000	1.1.2.13
+++ tree-scalar-evolution.h	18 Jun 2004 20:40:24 -0000
@@ -22,8 +22,6 @@ Software Foundation, 59 Temple Place - S
 #ifndef GCC_TREE_SCALAR_EVOLUTION_H
 #define GCC_TREE_SCALAR_EVOLUTION_H
 
-extern tree first_iteration_non_satisfying (enum tree_code, unsigned, 
-					    tree, tree);
 extern tree number_of_iterations_in_loop (struct loop *);
 extern tree get_loop_exit_condition (struct loop *);
 
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-loop-ivopts.c,v
retrieving revision 1.1.2.38
diff -d -u -p -r1.1.2.38 tree-ssa-loop-ivopts.c
--- tree-ssa-loop-ivopts.c	17 Jun 2004 18:25:12 -0000	1.1.2.38
+++ tree-ssa-loop-ivopts.c	18 Jun 2004 20:40:26 -0000
@@ -464,7 +464,7 @@ name_info (struct ivopts_data *data, tre
 static bool
 zero_p (tree arg)
 {
-  if (!arg)
+  if (arg == NULL_TREE)
     return true;
 
   return integer_zerop (arg);
Index: tree-ssa-loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop.c,v
retrieving revision 1.1.2.3.2.23
diff -d -u -p -r1.1.2.3.2.23 tree-ssa-loop.c
--- tree-ssa-loop.c	13 Jun 2004 20:58:19 -0000	1.1.2.3.2.23
+++ tree-ssa-loop.c	18 Jun 2004 20:40:26 -0000
@@ -259,6 +259,9 @@ struct tree_opt_pass pass_record_bounds 
 static void
 tree_ssa_loop_test (void)
 {
+  if (!current_loops)
+    return;
+
   scev_analysis ();
   analyze_all_data_dependences (current_loops);
 }
@@ -293,7 +296,8 @@ tree_elim_checks (void)
   if (!current_loops)
     return;
 
-  eliminate_redundant_checks ();
+  /* This pass is disabled for now.  */
+  /* eliminate_redundant_checks (); */
 }
 
 static bool


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