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] Some scev fixes


Hello,

during an attempt to use scev in the ivopts, I have found two problems
with scev:

1) The types are not always handled correctly (there are some uncasted
   integer_*_nodes in the tree-scalar-evolutions.c still, I have fixed
   just those that caused problems).
2) The test for latch edges in analyze_evolution_in_loop was incorrect
   (btw. the loops have just one latch edge in any case currently,
   so the chrec_merge call there seems superfluous).

+ there are some other small changes from the "scev in ivopts" attempt
I was lazy to separate.

Zdenek

Index: ChangeLog.lno
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ChangeLog.lno,v
retrieving revision 1.1.2.100
diff -c -3 -p -r1.1.2.100 ChangeLog.lno
*** ChangeLog.lno	23 Mar 2004 08:12:35 -0000	1.1.2.100
--- ChangeLog.lno	23 Mar 2004 08:26:59 -0000
***************
*** 1,3 ****
--- 1,24 ----
+ 2004-03-23  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+ 
+ 	* Makefile.in (SCEV_H): New.
+ 	(tree-ssa-loop-ivcanon.o, tree-ssa-loop-ivopts.o,
+ 	tree-scalar-evolution.o, tree-data-ref.o, tree-dg.o,
+ 	tree-elim-check.o, tree-vectorizer.o, tree-loop-linear.o,
+ 	lambda-code.o): Use it.
+ 	* tree-chrec.h (build_interval_chrec, build_polynomial_chrec,
+ 	build_exponential_chrec, build_peeled_chrec): Give a type to the
+ 	chrec node.
+ 	* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Preserve correct
+ 	type.
+ 	(analyze_evolution_in_loop): Fix test for edges from inside the loop.
+ 	(scev_initialize): New.
+ 	(scev_init): Use it.
+ 	(scev_finalize): New.
+ 	(scev_done): Use it.
+ 	* tree-flow-inline.h (loop_of_stmt): Handle initialization statements
+ 	without crash.
+ 	* tree-scalar-evolution.h (scev_initialize, scev_finalize): Declare.
+ 
  2004-03-23  Dorit Naishlos  <dorit@il.ibm.com>
  
          * tree-vectorizer.c: (vect_align_data_ref): Check for DECL_ALIGN
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.158.2.24
diff -c -3 -p -r1.903.2.158.2.24 Makefile.in
*** Makefile.in	22 Mar 2004 22:39:15 -0000	1.903.2.158.2.24
--- Makefile.in	23 Mar 2004 08:27:00 -0000
*************** TREE_FLOW_H = tree-flow.h tree-flow-inli
*** 708,713 ****
--- 708,714 ----
  PRETTY_PRINT_H = pretty-print.h input.h $(OBSTACK_H)
  DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H)
  C_PRETTY_PRINT_H = $(PRETTY_PRINT_H) $(C_COMMON_H) $(TREE_H)
+ SCEV_H = tree-scalar-evolution.h $(GGC_H) tree-chrec.h tree-fold-const.h
  
  #
  # Now figure out from those variables how to compile and link.
*************** tree-ssa-loop-unswitch.o : tree-ssa-loop
*** 1656,1666 ****
  tree-ssa-loop-ivcanon.o : tree-ssa-loop-ivcanon.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h $(PARAMS_H) tree-inline.h \
     output.h diagnostic.h $(TM_H) coretypes.h $(TREE_DUMP_H) flags.h \
!    tree-pass.h tree-scalar-evolution.h $(GGC_H) tree-chrec.h tree-fold-const.h
  tree-ssa-loop-ivopts.o : tree-ssa-loop-ivopts.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h varray.h $(EXPR_H) \
     output.h diagnostic.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
!    tree-pass.h $(GGC_H) $(RECOG_H) insn-config.h $(HASHTAB_H)
  tree-ssa-loop-manip.o : tree-ssa-loop-manip.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h \
     output.h diagnostic.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
--- 1657,1667 ----
  tree-ssa-loop-ivcanon.o : tree-ssa-loop-ivcanon.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h $(PARAMS_H) tree-inline.h \
     output.h diagnostic.h $(TM_H) coretypes.h $(TREE_DUMP_H) flags.h \
!    tree-pass.h $(SCEV_H)
  tree-ssa-loop-ivopts.o : tree-ssa-loop-ivopts.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h varray.h $(EXPR_H) \
     output.h diagnostic.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
!    tree-pass.h $(GGC_H) $(RECOG_H) insn-config.h $(HASHTAB_H) $(SCEV_H)
  tree-ssa-loop-manip.o : tree-ssa-loop-manip.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h \
     output.h diagnostic.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
*************** tree-chrec.o: tree-chrec.c $(CONFIG_H) $
*** 1697,1725 ****
  tree-scalar-evolution.o: tree-scalar-evolution.c $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(TM_H) errors.h $(GGC_H) $(TREE_H) $(RTL_H) \
     $(BASIC_BLOCK_H) diagnostic.h $(TREE_FLOW_H) $(TREE_DUMP_H) \
!    $(TIMEVAR_H) cfgloop.h tree-scalar-evolution.h tree-chrec.h \
!    tree-data-ref.h tree-fold-const.h tree-pass.h tree-vectorizer.h flags.h
  tree-data-ref.o: tree-data-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h \
!    tree-data-ref.h tree-scalar-evolution.h tree-fold-const.h tree-pass.h
  tree-dg.o: tree-dg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) flags.h \
     errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
!    $(TIMEVAR_H) cfgloop.h tree-chrec.h tree-data-ref.h tree-scalar-evolution.h \
!    tree-pass.h tree-dg.h $(TIMEVAR_H) $(TREE_DUMP_H) diagnostic.h \
!    tree-fold-const.h
  tree-elim-check.o: tree-elim-check.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h \
!    tree-scalar-evolution.h tree-fold-const.h tree-pass.h
  tree-vectorizer.o: tree-vectorizer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(OPTABS_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h tree-pass.h \
!    tree-vectorizer.h tree-data-ref.h tree-scalar-evolution.h tree-fold-const.h
  tree-loop-linear.o: tree-loop-linear.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(OPTABS_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h tree-pass.h \
!    tree-data-ref.h tree-scalar-evolution.h tree-fold-const.h
  c-call-graph.o : c-call-graph.c $(CONFIG_H) $(SYSTEM_H) $(C_TREE_H) \
     $(C_COMMON_H) diagnostic.h hard-reg-set.h $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
     $(TM_H) coretypes.h
--- 1698,1725 ----
  tree-scalar-evolution.o: tree-scalar-evolution.c $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(TM_H) errors.h $(GGC_H) $(TREE_H) $(RTL_H) \
     $(BASIC_BLOCK_H) diagnostic.h $(TREE_FLOW_H) $(TREE_DUMP_H) \
!    $(TIMEVAR_H) cfgloop.h $(SCEV_H) \
!    tree-data-ref.h tree-pass.h tree-vectorizer.h flags.h
  tree-data-ref.o: tree-data-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h \
!    tree-data-ref.h $(SCEV_H) tree-pass.h
  tree-dg.o: tree-dg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) flags.h \
     errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
!    $(TIMEVAR_H) cfgloop.h tree-data-ref.h \
!    tree-pass.h tree-dg.h $(TIMEVAR_H) $(TREE_DUMP_H) diagnostic.h $(SCEV_H)
  tree-elim-check.o: tree-elim-check.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h $(SCEV_H) \
!    tree-pass.h
  tree-vectorizer.o: tree-vectorizer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(OPTABS_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-pass.h \
!    tree-vectorizer.h tree-data-ref.h $(SCEV_H)
  tree-loop-linear.o: tree-loop-linear.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     errors.h $(GGC_H) $(OPTABS_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-pass.h \
!    tree-data-ref.h $(SCEV_H)
  c-call-graph.o : c-call-graph.c $(CONFIG_H) $(SYSTEM_H) $(C_TREE_H) \
     $(C_COMMON_H) diagnostic.h hard-reg-set.h $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
     $(TM_H) coretypes.h
*************** lambda-mat.o : lambda-mat.c lambda.h $(G
*** 1900,1907 ****
  lambda-trans.o: lambda-trans.c lambda.h $(GGC_H) $(SYSTEM_H) $(CONFIG_H) $(TM_H)
  lambda-code.o: lambda-code.c lambda.h $(GGC_H) $(SYSTEM_H) $(CONFIG_H) \
     errors.h $(TM_H) $(OPTABS_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h \
!    tree-data-ref.h tree-scalar-evolution.h tree-fold-const.h
  resource.o : resource.c $(CONFIG_H) $(RTL_H) hard-reg-set.h $(SYSTEM_H) coretypes.h \
     $(TM_H) $(BASIC_BLOCK_H) $(REGS_H) flags.h output.h resource.h function.h toplev.h \
     $(INSN_ATTR_H) except.h $(PARAMS_H) $(TM_P_H)
--- 1900,1907 ----
  lambda-trans.o: lambda-trans.c lambda.h $(GGC_H) $(SYSTEM_H) $(CONFIG_H) $(TM_H)
  lambda-code.o: lambda-code.c lambda.h $(GGC_H) $(SYSTEM_H) $(CONFIG_H) \
     errors.h $(TM_H) $(OPTABS_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \
!    $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h \
!    tree-data-ref.h $(SCEV_H)
  resource.o : resource.c $(CONFIG_H) $(RTL_H) hard-reg-set.h $(SYSTEM_H) coretypes.h \
     $(TM_H) $(BASIC_BLOCK_H) $(REGS_H) flags.h output.h resource.h function.h toplev.h \
     $(INSN_ATTR_H) except.h $(PARAMS_H) $(TM_P_H)
Index: tree-chrec.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-chrec.h,v
retrieving revision 1.1.2.5
diff -c -3 -p -r1.1.2.5 tree-chrec.h
*** tree-chrec.h	3 Mar 2004 18:42:15 -0000	1.1.2.5
--- tree-chrec.h	23 Mar 2004 08:27:00 -0000
*************** build_interval_chrec (tree low, 
*** 144,150 ****
    if (integer_zerop (tree_fold_int_minus (up, low)))
      return low;
    else
!     return build (INTERVAL_CHREC, NULL_TREE, low, up);
  }
  
  /* Build a polynomial chain of recurrence.  */
--- 144,150 ----
    if (integer_zerop (tree_fold_int_minus (up, low)))
      return low;
    else
!     return build (INTERVAL_CHREC, TREE_TYPE (low), low, up);
  }
  
  /* Build a polynomial chain of recurrence.  */
*************** build_polynomial_chrec (unsigned loop_nu
*** 154,160 ****
  			tree left, 
  			tree right)
  {
!   return build (POLYNOMIAL_CHREC, NULL_TREE, 
  		build_int_2 (loop_num, 0), left, right);
  }
  
--- 154,160 ----
  			tree left, 
  			tree right)
  {
!   return build (POLYNOMIAL_CHREC, TREE_TYPE (left), 
  		build_int_2 (loop_num, 0), left, right);
  }
  
*************** build_exponential_chrec (unsigned loop_n
*** 165,171 ****
  			 tree left, 
  			 tree right)
  {
!   return build (EXPONENTIAL_CHREC, NULL_TREE, 
  		build_int_2 (loop_num, 0), left, right);
  }
  
--- 165,171 ----
  			 tree left, 
  			 tree right)
  {
!   return build (EXPONENTIAL_CHREC, TREE_TYPE (left), 
  		build_int_2 (loop_num, 0), left, right);
  }
  
*************** build_peeled_chrec (unsigned loop_num, 
*** 176,182 ****
  		    tree left, 
  		    tree right)
  {
!   return build (PEELED_CHREC, NULL_TREE,
  		build_int_2 (loop_num, 0), left, right);
  }
  
--- 176,182 ----
  		    tree left, 
  		    tree right)
  {
!   return build (PEELED_CHREC, TREE_TYPE (left),
  		build_int_2 (loop_num, 0), left, right);
  }
  
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.64.2.5
diff -c -3 -p -r1.1.2.64.2.5 tree-flow-inline.h
*** tree-flow-inline.h	21 Mar 2004 03:20:19 -0000	1.1.2.64.2.5
--- tree-flow-inline.h	23 Mar 2004 08:27:00 -0000
*************** bsi_stmt_ptr (block_stmt_iterator i)
*** 583,589 ****
  static inline struct loop *
  loop_of_stmt (tree stmt)
  {
!   return bb_for_stmt (stmt)->loop_father;
  }
  
  static inline bool
--- 583,593 ----
  static inline struct loop *
  loop_of_stmt (tree stmt)
  {
!   basic_block bb = bb_for_stmt (stmt);
!   if (!bb)
!     return NULL;
! 
!   return bb->loop_father;
  }
  
  static inline bool
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.c,v
retrieving revision 1.1.2.22
diff -c -3 -p -r1.1.2.22 tree-scalar-evolution.c
*** tree-scalar-evolution.c	21 Mar 2004 03:20:20 -0000	1.1.2.22
--- tree-scalar-evolution.c	23 Mar 2004 08:27:00 -0000
*************** follow_ssa_edge_in_rhs (unsigned loop_nb
*** 1625,1631 ****
  			tree *evolution_of_loop)
  {
    bool res = false;
!   tree rhs0, rhs1;
  
    /* The RHS is one of the following cases:
       - an SSA_NAME, 
--- 1625,1631 ----
  			tree *evolution_of_loop)
  {
    bool res = false;
!   tree rhs0, rhs1, type = TREE_TYPE (rhs);
  
    /* The RHS is one of the following cases:
       - an SSA_NAME, 
*************** follow_ssa_edge_in_rhs (unsigned loop_nb
*** 1728,1734 ****
  	      if (res)
  		*evolution_of_loop = add_to_evolution 
  		  (loop_nb, *evolution_of_loop, 
! 		   chrec_fold_multiply (rhs1, integer_minus_one_node));
  	      
  	      else
  		{
--- 1728,1736 ----
  	      if (res)
  		*evolution_of_loop = add_to_evolution 
  		  (loop_nb, *evolution_of_loop, 
! 		   chrec_fold_multiply (rhs1,
! 					convert (type,
! 						 integer_minus_one_node)));
  	      
  	      else
  		{
*************** follow_ssa_edge_in_rhs (unsigned loop_nb
*** 1739,1745 ****
  		  if (res)
  		    *evolution_of_loop = add_to_evolution 
  		      (loop_nb, *evolution_of_loop, 
! 		       chrec_fold_multiply (rhs0, integer_minus_one_node));
  		}
  	    }
  	  
--- 1741,1749 ----
  		  if (res)
  		    *evolution_of_loop = add_to_evolution 
  		      (loop_nb, *evolution_of_loop, 
! 		       chrec_fold_multiply (rhs0,
! 					    convert (type,
! 						     integer_minus_one_node)));
  		}
  	    }
  	  
*************** follow_ssa_edge_in_rhs (unsigned loop_nb
*** 1753,1759 ****
  	      if (res)
  		*evolution_of_loop = add_to_evolution 
  		  (loop_nb, *evolution_of_loop, 
! 		   chrec_fold_multiply (rhs1, integer_minus_one_node));
  	    }
  	}
        
--- 1757,1765 ----
  	      if (res)
  		*evolution_of_loop = add_to_evolution 
  		  (loop_nb, *evolution_of_loop, 
! 		   chrec_fold_multiply (rhs1,
! 					convert (type,
! 						 integer_minus_one_node)));
  	    }
  	}
        
*************** follow_ssa_edge_in_rhs (unsigned loop_nb
*** 1767,1773 ****
  	  if (res)
  	    *evolution_of_loop = add_to_evolution 
  	      (loop_nb, *evolution_of_loop, 
! 	       chrec_fold_multiply (rhs0, integer_minus_one_node));
  	}
        
        else
--- 1773,1780 ----
  	  if (res)
  	    *evolution_of_loop = add_to_evolution 
  	      (loop_nb, *evolution_of_loop, 
! 	       chrec_fold_multiply (rhs0, convert (type,
! 						   integer_minus_one_node)));
  	}
        
        else
*************** analyze_evolution_in_loop (tree loop_phi
*** 2037,2043 ****
  {
    int i;
    tree evolution_function = chrec_not_analyzed_yet;
!   unsigned loop_nb = loop_num (loop_of_stmt (loop_phi_node));
    
    if (dump_file && (dump_flags & TDF_DETAILS))
      {
--- 2044,2052 ----
  {
    int i;
    tree evolution_function = chrec_not_analyzed_yet;
!   struct loop *loop = loop_of_stmt (loop_phi_node);
!   unsigned loop_nb = loop_num (loop);
!   basic_block def_bb;
    
    if (dump_file && (dump_flags & TDF_DETAILS))
      {
*************** analyze_evolution_in_loop (tree loop_phi
*** 2050,2100 ****
    for (i = 0; i < PHI_NUM_ARGS (loop_phi_node); i++)
      {
        tree arg = PHI_ARG_DEF (loop_phi_node, i);
        
        /* The arguments that are not SSA_NAMEs don't come from the
  	 loop's body.  */
!       if (TREE_CODE (arg) == SSA_NAME)
! 	{
! 	  tree ssa_chain = SSA_NAME_DEF_STMT (arg);
  	  
! 	  /* Select the edges that enter the loop body.  */
! 	  if (ssa_chain != NULL_TREE 
! 	      && TREE_CODE (ssa_chain) != NOP_EXPR
! 	      && (loop_depth (loop_of_stmt (ssa_chain)) 
! 		  >= loop_depth (loop_of_stmt (loop_phi_node))))
! 	    {
! 	      bool res;
! 	      /* Pass in the initial condition to the follow edge
! 		 function.  */
! 	      tree ev_fn = init_cond;
! 	      res = follow_ssa_edge 
! 		(loop_nb, ssa_chain, loop_phi_node, &ev_fn);
  	      
! 	      /* When it is impossible to go back on the same
! 		 loop_phi_node by following the ssa edges, the
! 		 evolution is represented by a peeled chrec, ie. the
! 		 first iteration, EV_FN has the value INIT_COND, then
! 		 all the other iterations it has the value of ARG.  */
! 	      if (res == false)
! 		{
! 		  /* FIXME: when dealing with periodic scalars, the
! 		     analysis of the scalar evolution of ARG would
! 		     create an infinite recurrence.  Solution: don't
! 		     try to simplify the peeled chrec at this time,
! 		     but wait until having more information.   */
! 		  tree arg_chrec = arg;
! 		  ev_fn = build_peeled_chrec 
! 		    (loop_nb, init_cond, arg_chrec);
  		  
! 		  /* Try to simplify the peeled chrec.  */
! 		  ev_fn = simplify_peeled_chrec (ev_fn);
! 		}
! 	      
! 	      /* When there are multiple edges that enter the loop,
! 		 merge their evolutions. */
! 	      evolution_function = chrec_merge (evolution_function, ev_fn);
! 	    }
  	}
      }
    
    if (dump_file && (dump_flags & TDF_DETAILS))
--- 2059,2108 ----
    for (i = 0; i < PHI_NUM_ARGS (loop_phi_node); i++)
      {
        tree arg = PHI_ARG_DEF (loop_phi_node, i);
+       tree ssa_chain, ev_fn;
+       bool res;
        
        /* The arguments that are not SSA_NAMEs don't come from the
  	 loop's body.  */
!       if (TREE_CODE (arg) != SSA_NAME)
! 	continue;
! 
!       ssa_chain = SSA_NAME_DEF_STMT (arg);
!       if (!ssa_chain)
! 	continue;
!       def_bb = bb_for_stmt (ssa_chain);
  	  
!       /* Select the edges that enter the loop body.  */
!       if (!def_bb
! 	  || !flow_bb_inside_loop_p (loop, def_bb))
! 	continue;
! 
!       /* Pass in the initial condition to the follow edge function.  */
!       ev_fn = init_cond;
!       res = follow_ssa_edge (loop_nb, ssa_chain, loop_phi_node, &ev_fn);
  	      
!       /* When it is impossible to go back on the same
! 	 loop_phi_node by following the ssa edges, the
! 	 evolution is represented by a peeled chrec, ie. the
! 	 first iteration, EV_FN has the value INIT_COND, then
! 	 all the other iterations it has the value of ARG.  */
!       if (!res)
! 	{
! 	  /* FIXME: when dealing with periodic scalars, the
! 	     analysis of the scalar evolution of ARG would
! 	     create an infinite recurrence.  Solution: don't
! 	     try to simplify the peeled chrec at this time,
! 	     but wait until having more information.   */
! 	  tree arg_chrec = arg;
! 	  ev_fn = build_peeled_chrec (loop_nb, init_cond, arg_chrec);
  		  
! 	  /* Try to simplify the peeled chrec.  */
! 	  ev_fn = simplify_peeled_chrec (ev_fn);
  	}
+ 	      
+       /* When there are multiple edges that enter the loop,
+ 	 merge their evolutions. */
+       evolution_function = chrec_merge (evolution_function, ev_fn);
      }
    
    if (dump_file && (dump_flags & TDF_DETAILS))
*************** initialize_scalar_evolutions_analyzer (v
*** 2724,2738 ****
      (build_int_2 (3333, 0), build_int_2 (4333, 0));
  }
  
! /* Initialize the analysis of scalar evolutions.  */
  
! static void
! scev_init (void)
  {
!   current_loops = tree_loop_optimizer_init (NULL);
!   if (!current_loops)
!     return;
!   
    scalar_evolution_info_st = NULL;
    already_instantiated_st = NULL;
    VARRAY_GENERIC_PTR_INIT (scalar_evolution_info_st, 100, 
--- 2732,2744 ----
      (build_int_2 (3333, 0), build_int_2 (4333, 0));
  }
  
! /* Initialize the analysis of scalar evolutions for LOOPS.  */
  
! void
! scev_initialize (struct loops *loops)
  {
!   current_loops = loops;
! 
    scalar_evolution_info_st = NULL;
    already_instantiated_st = NULL;
    VARRAY_GENERIC_PTR_INIT (scalar_evolution_info_st, 100, 
*************** scev_init (void)
*** 2745,2750 ****
--- 2751,2767 ----
    initialize_scalar_evolutions_analyzer ();
  }
  
+ /* Initialize the analysis of scalar evolutions.  */
+ 
+ static void
+ scev_init (void)
+ {
+   current_loops = tree_loop_optimizer_init (NULL);
+   if (!current_loops)
+     return;
+   scev_initialize (current_loops);
+ }
+ 
  /* Runs the analysis of scalar evolutions.  */
  
  static void
*************** scev_vectorize (void)
*** 2799,2804 ****
--- 2816,2831 ----
    vectorize_loops (current_loops, *scalar_evolution_info);
  }
  
+ /* Finalize the scalar evolution analysis.  */
+ 
+ void
+ scev_finalize (void)
+ {
+   VARRAY_CLEAR (*scalar_evolution_info);
+   VARRAY_CLEAR (*already_instantiated);
+   current_loops = NULL;
+ }
+ 
  /* Finalize the scalar evolution passes.  */
  
  static void
*************** scev_done (void)
*** 2806,2816 ****
  {
    if (current_loops)
      {
-       VARRAY_CLEAR (*scalar_evolution_info);
-       VARRAY_CLEAR (*already_instantiated);
        loop_optimizer_finalize (current_loops, NULL);
        cleanup_tree_cfg ();
-       current_loops = NULL;
      }
  
    dd_info_available = false;
--- 2833,2841 ----
  {
    if (current_loops)
      {
        loop_optimizer_finalize (current_loops, NULL);
+       scev_finalize ();
        cleanup_tree_cfg ();
      }
  
    dd_info_available = false;
Index: tree-scalar-evolution.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.h,v
retrieving revision 1.1.2.5
diff -c -3 -p -r1.1.2.5 tree-scalar-evolution.h
*** tree-scalar-evolution.h	3 Mar 2004 18:42:15 -0000	1.1.2.5
--- tree-scalar-evolution.h	23 Mar 2004 08:27:00 -0000
*************** extern tree number_of_iterations_in_loop
*** 26,31 ****
--- 26,33 ----
  extern void number_of_iterations_for_all_loops (varray_type *);
  extern tree get_loop_exit_condition (struct loop *);
  
+ extern void scev_initialize (struct loops *loops);
+ extern void scev_finalize (void);
  extern tree analyze_scalar_evolution (unsigned, tree);
  extern tree instantiate_parameters (unsigned, tree);
  


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