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] Fix PR tree-optimization/80426


On Wed, Apr 19, 2017 at 04:59:50PM +0200, Eric Botcazou wrote:
> > I know this attempts to be a copy of what is used elsewhere, but
> > at least there it is a result of wi::sub etc.
> > Wouldn't it be simpler to
> >   if (sgn == SIGNED && wi::neg_p (min_op1) && wi::neg_p (wmin))
> >     min_ovf = 1;
> >   else if (sgn == UNSIGNED && wi::ne_p (min_op1, 0))
> >     min_ovf = -1;
> > 
> > I mean, for SIGNED if min_op1 is 0, then wmin is 0 to and we want
> > min_ovf = 0;
> > If it is positive, wmin will be surely negative and again we want
> > min_ovf = 0.  Only if it is negative and its negation is negative
> > too we want min_ovf = 1 (i.e. wi::cmps (0, most_negative) result).
> > For UNSIGNED, if min_op1 is 0, again all 3 wi::cmp will yield
> > 0 and min_ovf = 0.  If it is non-zero, it is > 0, therefore it
> > the first wi::cmp will return -1, the second wi::cmp returns
> > 1 and the third one -1.
> 
> Fine with me.
> 
> > Is that what we want (e.g. the UNSIGNED case to overflow pretty much always
> > except for 0 which should be optimized away anyway)?
> 
> I think so, you'd better be very cautious with overflow and symbolic ranges.
> 
> > Or, shouldn't we just set if (!min_op0 && min_op1 && minus_p) min_op0 =
> > build_int_cst (expr_type, 0); before the if (min_op0 && min_op1) case
> > and don't duplicate that?
> 
> This isn't better than my version IMO.
> 
> Tested on x86_64-suse-linux, OK for mainline and 6 branch?

Ok, thanks.

	Jakub


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