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]: Improve ability to convert loops to perfect nests


On Sat, 2005-06-11 at 14:52 +0200, Sebastian Pop wrote:
> > +replace_uses_equiv_to_x_with_y (struct loop *loop, tree stmt, tree x, int xstep,
> > +				tree y)
> >  {
> >    ssa_op_iter iter;
> >    use_operand_p use_p;
> >  
> >    FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
> >      {
> > -      if (USE_FROM_PTR (use_p) == x)
> > +      tree use = USE_FROM_PTR (use_p);
> > +      tree step = NULL_TREE;
> > +      tree access_fn = NULL_TREE;
> > +      
> > +      
> > +      access_fn = instantiate_parameters
> > +	(loop, analyze_scalar_evolution (loop, use));
> > +      if (access_fn != NULL_TREE)
> > +	step = evolution_part_in_loop_num (access_fn, loop->num);
> > +      if ((step && int_cst_value (step) == xstep)
> 
> I don't think that it is safe to have a call to int_cst_value without
> previously checking that step really is an INTEGER_CST.  I should have
> proposed earlier a function like instantiate_parameters_to_affine that
> would give a guarantee on the kind of evolution.  I will post a patch
> around these lines.  But you'll still have to strip all the casts that
> are around the INTEGER_CST.
> 
Fixed thusly.


2005-06-11  Daniel Berlin  <dberlin@dberlin.org>

	* lambda-code.c (replace_uses_equiv_to_x_with_y): Verify the step
	is an INTEGER_CST before calling int_cst_value.

Index: lambda-code.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lambda-code.c,v
retrieving revision 2.43
diff -u -p -r2.43 lambda-code.c
--- lambda-code.c	10 Jun 2005 19:23:26 -0000	2.43
+++ lambda-code.c	11 Jun 2005 15:22:38 -0000
@@ -2184,7 +2184,8 @@ replace_uses_equiv_to_x_with_y (struct l
 	(loop, analyze_scalar_evolution (loop, use));
       if (access_fn != NULL_TREE)
 	step = evolution_part_in_loop_num (access_fn, loop->num);
-      if ((step && int_cst_value (step) == xstep)
+      if ((step && TREE_CODE (step) == INTEGER_CST 
+	   && int_cst_value (step) == xstep)
 	  || USE_FROM_PTR (use_p) == x)
 	SET_USE (use_p, y);
     }

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