This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Fix PR39233, SCEV, IVOPTs and overflow
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 ivopts should be fixed.
> 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.
This would change the semantics of simple_iv in an unintended way (possibly causing
missed optimizations),
Zdenek