From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id D1C75395B477 for ; Wed, 16 Nov 2022 15:59:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D1C75395B477 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x233.google.com with SMTP id k19so22379245lji.2 for ; Wed, 16 Nov 2022 07:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cBqGQI+O+7B6wP1Pi1SEmDGA5y+vTpiQPEPM4GxC5lQ=; b=BbjQnfLouqcsHRZj9NSL7r4rG9yED6XEPUAd4CuBGXGDUAFSEb8Hav4I5CzwZ7lnzI bz9n9+0/l2Mmlfl+ZLIMhrILIbwMMB449PQSQsxnRP7p8V5op7aGMwAkbJ7bsHIQNRRV rXwvjlmGPqIEjGZjwKYrZ6k0wAQIDv1TkK+sI5QXf8ljYvwnuwu++DT19w8viM0qywYL U+Gi31SAHGhNJWLL2Z47OhA9x6oiRjoeXMMhfLQlj8ISCmik1nmaIr/3SyEfGKFfbqR6 MKb5hfHg271CLWrQA6lBHhZmlO5j2JzBznpAr6B3OEAA4TUcMWPV5dSTWdjJ+849wCkZ Wtqw== 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:message-id :reply-to; bh=cBqGQI+O+7B6wP1Pi1SEmDGA5y+vTpiQPEPM4GxC5lQ=; b=XsuiDK8HTOz+N+Ix+PByUn4B8flayNnxLKIkeoC72ne8qnhiFjCgmCMYUaQsjfFvZV ZYMhSo4/24OUTeXEfuZSqW2ELQsJDLFGFQfCYYYh6crN0QyJ/nUAONwIPtZyXCz+0yv5 YLrZdY2UYA7ZB89DLkI6oN/lNYFi7irrh9f1dnO7/xL4hcW3QDmOPRUuGcHbslvTzPnV oBzKubUzsiaKz9s/nBNC0xRYwUie6EN1TzyPBKjh+VQ6RSfWAO8Mjsm/23943qcDJSpi CtIVf3Zgv1daU0sQrPx4Cf001CQ7d7uG4WloDCj7dSHp5Su2sIoTfkxq1s2pzYMV+ga7 vKKQ== X-Gm-Message-State: ANoB5pmhg9UO2qpw4seGqnv26BXhHuizzQDI/Qn/11GnwO0AnDkFRHtj CoXvZokNWLTbzlcV1gsD5aRLPMPNjKUtv3bUUoY= X-Google-Smtp-Source: AA0mqf6irJ8L8snwSjhV7OhmBoYeDp/EG/W9SwQg82gHDNaDxer6jE8cCYJBqQ324Sdnf5pvAH9aXgXOKqw5zUkmYXc= X-Received: by 2002:a2e:93c9:0:b0:26d:fc06:b7a9 with SMTP id p9-20020a2e93c9000000b0026dfc06b7a9mr8144373ljh.354.1668614377314; Wed, 16 Nov 2022 07:59:37 -0800 (PST) MIME-Version: 1.0 References: <20221112183048.389811-1-aldyh@redhat.com> In-Reply-To: From: Richard Biener Date: Wed, 16 Nov 2022 16:59:24 +0100 Message-ID: Subject: Re: [PATCH] [PR68097] Try to avoid recursing for floats in tree_*_nonnegative_warnv_p. To: Aldy Hernandez Cc: GCC patches , Andrew MacLeod , richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: On Tue, Nov 15, 2022 at 2:52 PM Aldy Hernandez wrote: > > On Mon, Nov 14, 2022 at 10:12 AM Richard Biener > wrote: > > > > On Sat, Nov 12, 2022 at 7:30 PM Aldy Hernandez wrote: > > > > > > It irks me that a PR named "we should track ranges for floating-point > > > hasn't been closed in this release. This is an attempt to do just > > > that. > > > > > > As mentioned in the PR, even though we track ranges for floats, it has > > > been suggested that avoiding recursing through SSA defs in > > > gimple_assign_nonnegative_warnv_p is also a goal. We can do this with > > > various ranger components without the need for a heavy handed approach > > > (i.e. a full ranger). > > > > > > I have implemented two versions of known_float_sign_p() that answer > > > the question whether we definitely know the sign for an operation or a > > > tree expression. > > > > > > Both versions use get_global_range_query, which is a wrapper to query > > > global ranges. This means, that no caching or propagation is done. > > > In the case of an SSA, we just return the global range for it (think > > > SSA_NAME_RANGE_INFO). In the case of a tree code with operands, we > > > also use get_global_range_query to resolve the operands, and then call > > > into range-ops, which is our lowest level component. There is no > > > ranger or gori involved. All we're doing is resolving the operation > > > with the ranges passed. > > > > > > This is enough to avoid recursing in the case where we definitely know > > > the sign of a range. Otherwise, we still recurse. > > > > > > Note that instead of get_global_range_query(), we could use > > > get_range_query() which uses a ranger (if active in a pass), or > > > get_global_range_query if not. This would allow passes that have an > > > active ranger (with enable_ranger) to use a full ranger. These passes > > > are currently, VRP, loop unswitching, DOM, loop versioning, etc. If > > > no ranger is active, get_range_query defaults to global ranges, so > > > there's no additional penalty. > > > > > > Would this be acceptable, at least enough to close (or rename the PR ;-))? > > > > I think the checks would belong to the gimple_stmt_nonnegative_warnv_p function > > only (that's the SSA name entry from the fold-const.cc ones)? > > > > I also notice the use of 'bool' for the "sign". That's not really > > descriptive. We > > have SIGNED and UNSIGNED (aka enum signop), not sure if that's the > > perfect match vs. NEGATIVE and NONNEGATIVE. Maybe the functions > > name is just bad and they should be known_float_negative_p? > > Yeah, SIGNED and UNSIGNED doesn't seem to be much clearer than "bool signbit". > > For instance, we have the following in frange: > > void set_nan (tree type, bool sign); > void update_nan (bool sign); > bool maybe_isnan (bool sign) const; > bool signbit_p (bool &signbit) const; > > I'm OK changing them to enum signop if you prefer. I'm just not > totally convinced it's more readable. > > ?? I think when talking about 'signbit' or 'sign' the old usual 'unsigned' type is better than bool. signbit_p feels a bit redundant (the _p). We could have another enum like signop just I think the obvious candidates { POSITIVE, NEGATIVE } or { NEGATIVE, NONNEGATIVE } aren't too great. The obvious alternative is to follow the existing uns_p (unsigned?) parameters and not use bool sign but bool unsigned_p, there 'true' and 'false' are obvious. For 'signbit_p' it would then be bool signbit_p (unsigned &signbit) being the true value of the bit (and the return value indicates the UNKNOWN case). Richard. > > Aldy >