From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id D3D5F385840B for ; Mon, 29 Nov 2021 14:48:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3D5F385840B Received: by mail-ed1-x534.google.com with SMTP id w1so73139524edc.6 for ; Mon, 29 Nov 2021 06:48:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=19o/9zXjRR1Rxh0zrf1V7J3ojlY/nBCBaDe0E7bsIR8=; b=5GZ4hn++rrXOIfqroVRmqJTvTO+MK7YzP9T8gTwo01T1Yl4b4/MSz+7EJIR5zDPwCX wx1P9wFYuCaXykeZQZd1wazgCDD8XJt4AenwYaxCMu8FcGisefhmTal82XgzJ7iXg13H sYTd9xsoeyHE4D6GGEcIxrYgRTB4NzmQXSNCKOLyQdUlYEvfurTJrRxuhwi7qJW2kAIE hwEP2tvnDxAyuMfrjL/xnCqJ12NSFU6WizdcRzSXLqnjCx9OAoRXL0H2zbi6WgUol3CJ 87WITjqXH78S8p+SNbY7afSg88vMYO1Mj0CHcjIUcCvmbuHG+6FyPSxeQFp4vIprSvwH IzvQ== X-Gm-Message-State: AOAM533OItVbq/5XvnnXtPdt8LfPlFAHLgTEI3fdmHfJttId3Qk8F37Q zgr6V8sy4LmVyJUM39MLQDboKNiLeqApUPKb8Gk= X-Google-Smtp-Source: ABdhPJzoMPn3CK/V5EyVIXbBtcev8Log33dWt1utWK2kLmj1bMjpvOQp5rq/ZoPCQ/bRHnOwPQughJGiDHspNSL5GrQ= X-Received: by 2002:aa7:c313:: with SMTP id l19mr74098208edq.209.1638197317777; Mon, 29 Nov 2021 06:48:37 -0800 (PST) MIME-Version: 1.0 References: <20211129140050.82907-1-aldyh@redhat.com> <48e8a1e2-940e-0dc7-999a-2f1c4f4d9b53@gmail.com> In-Reply-To: <48e8a1e2-940e-0dc7-999a-2f1c4f4d9b53@gmail.com> From: Richard Biener Date: Mon, 29 Nov 2021 15:48:26 +0100 Message-ID: Subject: Re: [PATCH] Remove can_throw_non_call_exceptions special case from operator_div::wi_fold. To: Jeff Law Cc: Aldy Hernandez , GCC patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Nov 2021 14:48:40 -0000 On Mon, Nov 29, 2021 at 3:39 PM Jeff Law 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) > > > --- > > gcc/range-op.cc | 7 ------- > > gcc/testsuite/gcc.dg/pr103451.c | 17 +++++++++++++++++ > > 2 files changed, 17 insertions(+), 7 deletions(-) > > create mode 100644 gcc/testsuite/gcc.dg/pr103451.c > > > > diff --git a/gcc/range-op.cc b/gcc/range-op.cc > > index bbf2924f815..6fe5f1cb4e0 100644 > > --- a/gcc/range-op.cc > > +++ b/gcc/range-op.cc > > @@ -1832,13 +1832,6 @@ operator_div::wi_fold (irange &r, tree type, > > return; > > } > > > > - // If flag_non_call_exceptions, we must not eliminate a division by zero. > > - if (cfun->can_throw_non_call_exceptions) > > - { > > - r.set_varying (type); > > - return; > > - } > > - > > // If we're definitely dividing by zero, there's nothing to do. > > if (wi_zero_p (type, divisor_min, divisor_max)) > > { > > diff --git a/gcc/testsuite/gcc.dg/pr103451.c b/gcc/testsuite/gcc.dg/pr103451.c > > new file mode 100644 > > index 00000000000..b83646d0b83 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/pr103451.c > > @@ -0,0 +1,17 @@ > > +// { dg-do compile } > > +// { dg-options "-O2 -w" } > ISTM that what you want to test for is that the division by zero remains > in the IL for -fnon-call-exceptions. > > jeff >