On Fri, 28 Oct 2016, Marc Glisse wrote:

> On Wed, 28 Sep 2016, Richard Biener wrote:
> 
> > The following patch implements patterns to catch x / abs (x)
> > and x / -x, taking advantage of undefinedness at x == 0 as
> > opposed to the PR having testcases with explicit != 0 checks.
> > 
> > Bootstrap / regtest pending on x86_64-unknown-linux-gnu.
> > 
> > Richard.
> > 
> > 2016-09-28  Richard Biener  <rguent...@suse.de>
> > 
> >     PR middle-end/77407
> >     * match.pd: Add X / abs (X) -> X < 0 ? -1 : 1 and
> >     X / -X -> -1 simplifications.
> 
> I notice that we still have the following comment a few lines above:
> 
> /* Make sure to preserve divisions by zero.  This is the reason why
>    we don't simplify x / x to 1 or 0 / x to 0.  */
> 
> Did we give up on preserving divisions by 0? Can we now do the 2
> simplifications listed by the comment?

At some point there was at least diagnostics fallout when doing them.
There may be also undefined sanitizer fallout depending on when we
instrument for that.

But in general yes, we do want to do the two simplifications.  Maybe
we can compromise (in case of early fallout) to do them on GIMPLE
only.

We could at least add them with a proper nonzero_p predicate.

Richard.

Reply via email to