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][RFC] Fix PR39233, SCEV, IVOPTs and overflow


On Tue, 24 Feb 2009, Richard Guenther wrote:

> On Mon, 23 Feb 2009, Zdenek Dvorak wrote:
> 
> > Hi,
> > 
> > > > > Can you have a look at the testcase in PR39233?
> > > > 
> > > > here is a patch; I do not have time to test it just now.  It could be
> > > > simplified by casting the values to unsigned type in
> > > > add_iv_value_candidates unconditionally (most of the patch makes
> > > > us push the value of the no_overflow flag there, so that we do not
> > > > add these casts when not necessary).
> > > 
> > > I am going to give the patch testing, most of it looks like useful
> > > cleanup.  Note that using unsigned_type_for is probably not a good
> > > idea, so I'll change it to use get_nonstandard_integer_type instead.
> > 
> > actually, looking at the issue again, there already is a code dealing
> > with this problem in add_candidate_1; unfortunately, there is a test
> > excluding pointers from being casted to a safe type, which causes
> > PR39233.  So, it should suffice to remove that test,
> 
> Indeed, that works.  The previous patch bootstrapped and tested ok,
> I'm going to test the simpler one now.

Done as follows.  Bootstrapped and tested on x86_64-unknown-linux-gnu,
applied to trunk.

Thanks,
Richard.

2009-02-24  Richard Guenther  <rguenther@suse.de>
	Zdenek Dvorak  <ook@ucw.cz>

	PR tree-optimization/39233
	* tree-ssa-loop-ivopts.c (add_candidate_1): Do not except pointers
	from converting them to a generic type.

	* gcc.c-torture/execute/pr39233.c: New testcase.

Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
*** gcc/tree-ssa-loop-ivopts.c	(revision 144381)
--- gcc/tree-ssa-loop-ivopts.c	(working copy)
*************** add_candidate_1 (struct ivopts_data *dat
*** 2071,2079 ****
      {
        orig_type = TREE_TYPE (base);
        type = generic_type_for (orig_type);
!       /* Don't convert the base to the generic type for pointers as the generic
! 	 type is an integer type with the same size as the pointer type.  */
!       if (type != orig_type && !POINTER_TYPE_P (orig_type))
  	{
  	  base = fold_convert (type, base);
  	  step = fold_convert (type, step);
--- 2071,2077 ----
      {
        orig_type = TREE_TYPE (base);
        type = generic_type_for (orig_type);
!       if (type != orig_type)
  	{
  	  base = fold_convert (type, base);
  	  step = fold_convert (type, step);
Index: gcc/testsuite/gcc.c-torture/execute/pr39233.c
===================================================================
*** gcc/testsuite/gcc.c-torture/execute/pr39233.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/execute/pr39233.c	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+ extern void abort (void);
+ 
+ __attribute__((noinline)) void
+ foo (void *p)
+ {
+   long l = (long) p;
+   if (l < 0 || l > 6)
+     abort ();
+ }
+ 
+ int
+ main ()
+ {
+   short i;
+   for (i = 6; i >= 0; i--)
+     foo ((void *) (long) i);
+   return 0;
+ }


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