[PATCH] Remove can_throw_non_call_exceptions special case from operator_div::wi_fold.

Aldy Hernandez aldyh@redhat.com
Mon Nov 29 15:24:40 GMT 2021


On Mon, Nov 29, 2021 at 3:48 PM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Mon, Nov 29, 2021 at 3:39 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
> >
> >
> >
> > On 11/29/2021 7:00 AM, Aldy Hernandez via Gcc-patches wrote:
> > > As discussed in the PR.  The code makes no difference, so whatever test
> > > we added this special case for has been fixed or is being papered over.
> > > I think we should fix any fall out upstream.
> > >
> > > [Unless Andrew can remember why we added this and it still applies.]
> > >
> > > Tested on x86-64 Linux.
> > >
> > > OK for trunk?
> > >
> > >       PR 103451
> > >
> > > gcc/ChangeLog:
> > >
> > >       * range-op.cc (operator_div::wi_fold): Remove
> > >       can_throw_non_call_exceptions special case.
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > >       * gcc.dg/pr103451.c: New test.
> > I'll defer to Andrew, but it seems wrong to me.  The whole point is to
> > set the result to varying so that we don't know the result and never
> > remove the division which is critical for -fnon-call-exceptions.
>
> But that has nothing to do with computing the value range for
> the result which is only accessible when the stmt does _not_ throw ...
>
> That is, if we compute non-VARYING here and because of that
> remove the stmt then _that's_ the place to fix (IMO)

Ughh, I think you're both right.

We should fix this upstream AND we should test for the presence of the
division by 0 in the optimized dump.

Of course doing both opens a can of worms.  The division by zero can
be cleaned up by (at least) DCE, DSE, and the code sinking passes.
I've fixed all 3 in the attached (untested) patch.  Dunno what y'all
want to do at this point.

Aldy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Remove-can_throw_non_call_exceptions-special-case-fr.patch
Type: text/x-patch
Size: 3762 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211129/b20bdc34/attachment.bin>


More information about the Gcc-patches mailing list