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 28ADF3895FE6 for ; Tue, 15 Nov 2022 13:52:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 28ADF3895FE6 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=1668520348; 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=AO6oXtN/TC6Job5fLb/qUekqE/SMkuSlzxFd4UGollo=; b=YvHykoCRJlDjS/pLfBFbn5tfozg1d36fnMx082nvRZyBQgP/klV0GgrJM7mNI7Po7HPHe1 GIhaUjUUq4Va41xNF1uAaB55lnx01riry5jqtcJvKvLnb18boMkr8THJJxmW0qcSHKW0/I /b9L8Ubn++lILWlFArVLUTBX9VYZXLA= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-338-4gvJZhfnMSCJw0fTDTc_kQ-1; Tue, 15 Nov 2022 08:52:27 -0500 X-MC-Unique: 4gvJZhfnMSCJw0fTDTc_kQ-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-352e29ff8c2so137039857b3.21 for ; Tue, 15 Nov 2022 05:52:27 -0800 (PST) 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=AO6oXtN/TC6Job5fLb/qUekqE/SMkuSlzxFd4UGollo=; b=kMSM11cnim5BsVUa2olKIGNRtxL9zcoxp0B5UBCJ8MFTL1x3f6ijBMsvfWa2MHpgRM 6RDqAI/Sxo7hy/H2SpkSU992bhQfA0ybEs/6Rxdecr6xom0G9PB3unPepffx2UPmQRGG 75qMUc2h0MYJyVJ51OdJyOOr/A7TzsiWK+pjfx+HwTfPc1dDjenNK00Gs6lFD8M+Wr0Z h0KzOHoSmyGGu1TGLbn9gzQcL84ECe5yijawwkhHz5g39afo4FjRvBu+cOTPxjkytC3z zcq57TSnnJ4cVGruWvZHRckB3oSPK9o0peiDVVoq06cdRuGA9JifT4TDY3JBfAIXKc5k ax2Q== X-Gm-Message-State: ANoB5pn8wxuWDhA56Me8ENjz7q+km058fLsPcLtx/y7o2H8oNJ0QYWlk u+bEo5CHFqj3F4eiluVgLFnJ1f9kIXsReJIgSJ+1kSZRrDXnf2H1PgIPal2i+0Yw1ZkjClsAUGV rqGtr5lS/OfgW8pDIDNor1NtdDzBGmgyEcQ== X-Received: by 2002:a25:d605:0:b0:6cf:b8f4:2fe2 with SMTP id n5-20020a25d605000000b006cfb8f42fe2mr16983281ybg.80.1668520346860; Tue, 15 Nov 2022 05:52:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/4Na9fblaGEwIfW9lfh45CJhPRISWrea3Ab2FnHVvhC/APLga7dAxqNo2z4/lp5OXCIgbamQgrWppAjWh2Fo= X-Received: by 2002:a25:d605:0:b0:6cf:b8f4:2fe2 with SMTP id n5-20020a25d605000000b006cfb8f42fe2mr16983264ybg.80.1668520346586; Tue, 15 Nov 2022 05:52:26 -0800 (PST) MIME-Version: 1.0 References: <20221112183048.389811-1-aldyh@redhat.com> In-Reply-To: From: Aldy Hernandez Date: Tue, 15 Nov 2022 14:52:15 +0100 Message-ID: Subject: Re: [PATCH] [PR68097] Try to avoid recursing for floats in tree_*_nonnegative_warnv_p. To: Richard Biener Cc: GCC patches , Andrew MacLeod , richard.sandiford@arm.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: 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. ?? Aldy