This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix PR tree-optimization/80426
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Apr 2017 17:05:09 +0200
- Subject: Re: [patch] Fix PR tree-optimization/80426
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8CD51C054C5E
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8CD51C054C5E
- References: <7983915.vF9qLkl6hX@polaris> <20170419092947.GE1809@tucnak> <12981441.W0lox0l1Ju@polaris>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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