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 Thu, 19 Feb 2009, Zdenek Dvorak wrote:

> Hi,
> 
> > Comments?  Or even ideas (ideas suitable for 4.4 - I have enough
> > for later, if you have spare time ask me)?
> 
> what is the purpose of the change you propose for simple_iv?  
> The result of simple_iv is guaranteed not to wrap only if iv->no_overflow is true
> (so simple_iv may return a description of a wrapping iv in type for that
> the overflow is undefined).  Hence this change seems wrong:
> 
> > !   /* If we folded casts and the result is a type where overflow is
> > !      undefined the IV may not be simple as it can have introduced
> > !      undefined overflow that wasn't there before.  */
> > !   if (!iv->no_overflow
> > !       && folded_casts
> > !       && (TYPE_OVERFLOW_UNDEFINED (type)
> > ! 	  || POINTER_TYPE_P (type)))
> > !     return false;
> 
> I guess there is an error at some place that uses of simple_iv, assuming
> a different semantics,

The "iv->no_overflow" flag is lost once the IV is put into the IL.  In
the case in question IVOPTs puts in a IV which type has undefined overflow
semantics (and iv->no_overflow is not set), later VRP based on that
undefinedness optimizes the code, which is wrong (well, the IV 
substitution is wrong).

So what the above change does is return false if the IV cannot be used
as replacement for any other IV it is based on.

Richard.


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