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] Fix reset_evolution_in_loop bug


On Mon, Jun 06, 2005 at 02:09:21PM +0200, Sebastian Pop wrote:
> I installed the following patch in the gcc-4_0-branch after a
> bootstrap and regtest on i686.
> 
> @@ -717,7 +724,7 @@ reset_evolution_in_loop (unsigned loop_n
>  {
>    if (TREE_CODE (chrec) == POLYNOMIAL_CHREC
>        && CHREC_VARIABLE (chrec) > loop_num)
> -    return build 
> +    return build2
>        (TREE_CODE (chrec), 
>         build_int_cst (NULL_TREE, CHREC_VARIABLE (chrec)), 
>         reset_evolution_in_loop (loop_num, CHREC_LEFT (chrec), new_evol), 

While looking at a (whitespace caused) merge conflict, I have noticed
that this really can't be right.

POLYNOMIAL_CHREC is 3 operand tree, so using build2 to create
it (and creating it with INTEGER_CST TREE_TYPE) IMHO must have never worked
realy well.

Here is (so far untested) patch.  Ok for HEAD/4.0 if testing succeeds?

2005-06-06  Jakub Jelinek  <jakub@redhat.com>

	* tree-chrec.c (reset_evolution_in_loop): Use build3 instead of
	build2.

--- gcc/tree-chrec.c.jj	2005-06-06 17:27:28.000000000 +0200
+++ gcc/tree-chrec.c	2005-06-06 17:45:40.000000000 +0200
@@ -725,12 +725,16 @@ reset_evolution_in_loop (unsigned loop_n
 {
   if (TREE_CODE (chrec) == POLYNOMIAL_CHREC
       && CHREC_VARIABLE (chrec) > loop_num)
-    return build2 
-      (TREE_CODE (chrec), 
-       build_int_cst (NULL_TREE, CHREC_VARIABLE (chrec)), 
-       reset_evolution_in_loop (loop_num, CHREC_LEFT (chrec), new_evol), 
-       reset_evolution_in_loop (loop_num, CHREC_RIGHT (chrec), new_evol));
-  
+    {
+      tree left = reset_evolution_in_loop (loop_num, CHREC_LEFT (chrec),
+					   new_evol);
+      tree right = reset_evolution_in_loop (loop_num, CHREC_RIGHT (chrec),
+					    new_evol);
+      return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left),
+		     build_int_cst (NULL_TREE, CHREC_VARIABLE (chrec)),
+		     left, right);
+    }
+
   while (TREE_CODE (chrec) == POLYNOMIAL_CHREC
 	 && CHREC_VARIABLE (chrec) == loop_num)
     chrec = CHREC_LEFT (chrec);

	Jakub


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