From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1D3273858D1E for ; Mon, 19 Sep 2022 12:52:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D3273858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663591928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hhmoOgigSn16Kruu2jJWrYHeuPAetNavcC6m6gUCcl0=; b=M3E9JDWTyK0sP6+3g5fy7BJxscRcSs6a6iINiLqJcUSLRAkSwQ9GIwBaqTivDbb2YBMYYf TySDY16beWSIvNn9CwmyGIH7dco2d5nZW+hFgdgNraM0Bq/cDu/ty4sonfKmLRg7BJ6Oeo UhSq/21keMBY46scT8n99QDoUxnrJhs= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-30-ckWGE_QZOvG3Ojw960gEWg-1; Mon, 19 Sep 2022 08:51:59 -0400 X-MC-Unique: ckWGE_QZOvG3Ojw960gEWg-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-10e88633e1cso14587443fac.21 for ; Mon, 19 Sep 2022 05:51:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=hhmoOgigSn16Kruu2jJWrYHeuPAetNavcC6m6gUCcl0=; b=vHwuaaMscQbPnh2EZ5VgCsz5pnU9axa13BL4S5Tu3/KIMDZzDn5UTt3czemt5Q6IQq qHc9inPjRJRlOALQ8WjBVnl6fwRcagBfQ4j9OXrxbzeEbbB3bL7hLt8v9pwuKb0wZM11 nPlKN+LN/terV71YwB0Ccbm26ajcWKA2p2YsF9DsT9JyBvJ0hS+syqxWpWSTo51mi0ry 654lPCDv5DBgU4X2+kXr5hgM24lz6q24XPlnpsfCeXyPJVqUWf6Fwi5rI/+jQs+FGnWl 93DbwB16uwcT2pWgWLy2fTPX1H0RMRM/KDmp9/RSX3geMOmXjYQ1sjwRIMW0qLmvx6mK A9bQ== X-Gm-Message-State: ACrzQf0+K344dvjBux1T0O0gLwpEGAqeTM4G7LgS97gPdeTc6J9g7XRW ugFSv07LiW7SxDF8Rhqc0icAuMt2T3N1aoM/r8CYMbgTY8HlW7MUtYnd7voELAzFpfJdHeoCatc D2NoRzT+DNAN5jP3fL6zBuhGQiOy62YpB4w== X-Received: by 2002:a05:6808:1a98:b0:34f:8b40:6263 with SMTP id bm24-20020a0568081a9800b0034f8b406263mr7939794oib.265.1663591919148; Mon, 19 Sep 2022 05:51:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6izWb20Gao9N4DC96DtNweLOGf0oFOp+ZyBF6P3Ly74s+RG3GNyDqg5j1Cctet+0EreuSMes8zPuMzpBuhQzA= X-Received: by 2002:a05:6808:1a98:b0:34f:8b40:6263 with SMTP id bm24-20020a0568081a9800b0034f8b406263mr7939786oib.265.1663591918871; Mon, 19 Sep 2022 05:51:58 -0700 (PDT) MIME-Version: 1.0 References: <20220919075901.1798294-1-aldyh@redhat.com> In-Reply-To: From: Aldy Hernandez Date: Mon, 19 Sep 2022 14:51:47 +0200 Message-ID: Subject: Re: [PATCH] [PR68097] frange::set_nonnegative should not contain -NAN. To: Richard Biener Cc: GCC patches , Jakub Jelinek , Andrew MacLeod X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="0000000000006063cd05e9072da3" X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000006063cd05e9072da3 Content-Type: text/plain; charset="UTF-8" On Mon, Sep 19, 2022 at 10:14 AM Richard Biener wrote: > > On Mon, Sep 19, 2022 at 9:59 AM Aldy Hernandez wrote: > > > > ISTM that a specifically nonnegative range should not contain -NAN, > > otherwise signbit_p() would return false, because we'd be unsure of the > > sign. > > > > Do y'all agree? > > what tree_expr_nonnegative_p actually means isn't 100% clear. For REAL_CST > it actually looks at the sign-bit but we have > > (simplify > /* copysign(x,y) -> fabs(x) if y is nonnegative. */ > (COPYSIGN_ALL @0 tree_expr_nonnegative_p@1) > (abs @0)) > > is abs (@0) OK for sNaNs and -NaN/+NaN? At least for real_value's, ABS_EXPR works on NAN's. There's no special code dealing with them. We just clear the sign bit: real_arithmetic: case ABS_EXPR: *r = *op0; r->sign = 0; break; > > And we have > > /* Convert abs[u] (X) where X is nonnegative -> (X). */ > (simplify > (abs tree_expr_nonnegative_p@0) > @0) > > where at least sNaN -> qNaN would be dropped? > > And of course > > (simplify > /* signbit(x) -> 0 if x is nonnegative. */ > (SIGNBIT tree_expr_nonnegative_p@0) > { integer_zero_node; }) > > that is, is tree_expr_nonnegative_p actually tree_expr_sign or > does tree_expr_nonnegative (x) mean x >= (typeof(X)) 0 > or !(x < (typeof(X))0)? I have no idea, but I'm happy to have frange::set_nonnegative() do whatever you agree on. Actually TBH, ranger only uses set_nonnegative for call's, not much else: if (range_of_builtin_call (r, call, src)) ; else if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p)) r.set_nonnegative (type); else if (gimple_call_nonnull_result_p (call) || gimple_call_nonnull_arg (call)) r.set_nonzero (type); else r.set_varying (type); but I guess it's good we do the right thing for correctness sake, and if it ever gets used by someone else. > > That said, 'set_nonnegative' could be interpreted to be without > NaNs? Sounds good to me. How's this? Aldy --0000000000006063cd05e9072da3 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-PR68097-Non-negative-frange-s-should-not-contain-NAN.patch" Content-Disposition: attachment; filename="0001-PR68097-Non-negative-frange-s-should-not-contain-NAN.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l88ro13n0 RnJvbSA3ZWViODFhOTUxNjY2M2Q1ODllNjkyYjI3ODkwN2JiNWYzZDYwZWEwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbGR5IEhlcm5hbmRleiA8YWxkeWhAcmVkaGF0LmNvbT4KRGF0 ZTogU3VuLCAxOCBTZXAgMjAyMiAxNjoyNDozNiArMDIwMApTdWJqZWN0OiBbUEFUQ0hdIFtQUjY4 MDk3XSBOb24tbmVnYXRpdmUgZnJhbmdlJ3Mgc2hvdWxkIG5vdCBjb250YWluIE5BTnMuCgoJUFIg NjgwOTcvdHJlZS1vcHRpbWl6YXRpb24KCmdjYy9DaGFuZ2VMb2c6CgoJKiB2YWx1ZS1yYW5nZS5j YyAoZnJhbmdlOjpzZXRfbm9ubmVnYXRpdmUpOiBDbGVhciBOQU4uCgkocmFuZ2VfdGVzdHNfc2ln bmVkX3plcm9zKTogTmV3IHRlc3QuCi0tLQogZ2NjL3ZhbHVlLXJhbmdlLmNjIHwgNSArKysrKwog MSBmaWxlIGNoYW5nZWQsIDUgaW5zZXJ0aW9ucygrKQoKZGlmZiAtLWdpdCBhL2djYy92YWx1ZS1y YW5nZS5jYyBiL2djYy92YWx1ZS1yYW5nZS5jYwppbmRleCA2N2Q1ZDdmYTkwZi4uNmU3MDNjN2Vi NDMgMTAwNjQ0Ci0tLSBhL2djYy92YWx1ZS1yYW5nZS5jYworKysgY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