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 PR36817


On Thu, 21 Aug 2008, cnstar9988 at gmail dot com wrote:

> I am sorry for wrong test for 4.3.0.
> 
> =================================================
> I rebuild my gcc 4.3.0 on 2.6.9-42.7AXsmp with gmp 4.2.3 + mpfr 2.3.1.
> 
> And make a test again. It works fail.
> But the following code well on gcc 4.3.2-RC1. 
> =================================================
>  void xxx()
>  {
>   unsigned i;
>   unsigned*p=2;  /* 2 is ok, but failed with 0 */
>   for(i=0;i<4;++i)
>   {
>    *p++=0;
>   }
>   for(i=0;i<4;++i)
>   {
>    *p++=0;
>   }
>  }

The following fix makes it obvious that _only_ pointer(!) induction
variables with zero(!) base are affected - thus I think this can
wait until after 4.3.2.

Bootstrapped and tested on x86_64-unknown-linux-gnu, I'll apply it
to the trunk in a moment where this issue is latent.

Richard.

2008-08-21  Richard Guenther  <rguenther@suse.de>

	PR middle-end/36817
	* tree-chrec.c (chrec_apply): Always call chrec_fold_plus which
	makes sure to produce a result of the correct type.

	* gcc.c-torture/compile/pr36817.c: New testcase.

Index: gcc/tree-chrec.c
===================================================================
*** gcc/tree-chrec.c	(revision 139376)
--- gcc/tree-chrec.c	(working copy)
*************** chrec_apply (unsigned var,
*** 579,586 ****
        /* "{a, +, b} (x)"  ->  "a + b*x".  */
        x = chrec_convert_rhs (type, x, NULL_TREE);
        res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x);
!       if (!integer_zerop (CHREC_LEFT (chrec)))
! 	res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
      }
    
    else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
--- 579,585 ----
        /* "{a, +, b} (x)"  ->  "a + b*x".  */
        x = chrec_convert_rhs (type, x, NULL_TREE);
        res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x);
!       res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
      }
    
    else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
Index: gcc/testsuite/gcc.c-torture/compile/pr36817.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr36817.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr36817.c	(revision 0)
***************
*** 0 ****
--- 1,10 ----
+ void xxx()
+ {
+   unsigned i;
+   unsigned *p=0;
+   for(i=0; i<4; ++i)
+     *p++=0;
+   for(i=0; i<4; ++i)
+     *p++=0;
+ }
+ 


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