From patchwork Wed Sep 14 15:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2302:b0:79:6ae5:3758 with SMTP id gv2csp744002dyb; Wed, 14 Sep 2022 08:11:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR4JeK2jVkYBHv8no4zNjM/C3vmyVn1S1uNnFo9Pf/YJlXVIBTp7Ms5jtLpCS5Fa7FDvBSlR X-Received: by 2002:a17:907:75c2:b0:770:7bb7:9412 with SMTP id jl2-20020a17090775c200b007707bb79412mr26261421ejc.638.1663168311272; Wed, 14 Sep 2022 08:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663168311; cv=none; d=google.com; s=arc-20160816; b=bQ0rOojSg9jxG8Sz6VNfSuYbf96INpjTJVnjd3NvhS2BwuiFYMomm5EDJdIRkmDYYr Ne9MRcOGSqKJtMxcVUS0jOXFjWeEk7CfsuJVd5wmB6pMHwqFwRPSdrUTmpFVzsqtrZ9D BkOtn4MA7bmIz9moV8Tntdbj+9hdPNWfsM8fTA9rzWWpmr9uHTrwJLzrv1b13+VA8pqQ iFhSDrK+pWVpBC42IAPbaEgTG13Fqx2cRfu5bubLAbp0+K8O0gO8SQWqg8cRxqDmp8LO 2KS5JDYHPxTJjHAlODuwf67LD8Rnq9wm0EU+UlWR7b6ck7x1Cj0owE/MtwuPFVPXDFZF r4Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=swmNjsd7KprW6GnrF4al5zgekD0ZxPQi4M9LAKxIpoQ=; b=GAfTmK6Y1mfaE5R6PQGlBCHIcndi0LEJT38ievw9UVfJSYbPlMNOVcq24k1iMoLDRg MN6B5ZAzFouqOQJslmGoIS6vwApd7vuU5sF9eMxzZMyHZEEUBIzZsmLEMam0cwAgVzAl d9yuq9dGxBCoV7hI/1DGck3cPEBlxgsgY84rVWy4wYlMHYZ7j78gfZKx5ggYSyKg4iOP TjKs0dtwxznoRhezpNdG21AgSn2LRYw1tOca9Zr46J5IYyCv2aESZvc0/51c4y42+EWK OGlXAbqatxSD33bkDuhIzrz3UzGVPljaRvM5L5GXoEY7CEISNISlDGB+1ilXz0O3L5YF M1CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=IZHkCtnA; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cs12-20020a170906dc8c00b0073d80c9dc85si11500718ejc.459.2022.09.14.08.11.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=IZHkCtnA; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 25EF9384BC32 for ; Wed, 14 Sep 2022 15:10:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25EF9384BC32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663168251; bh=swmNjsd7KprW6GnrF4al5zgekD0ZxPQi4M9LAKxIpoQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=IZHkCtnA0fUKRczg6CseRsW8KDCnMVRfXGgj7fayGQ0PMlIYELttF8a4Y4OwpHhFc Gv/kxQW8smLsGcBVs0XDDUUK2lL8a5r8OghftjS/vLYboRWN4ZS2QibI4MAqCzfWou JGvFAIk4aNEjf+f+XxVQ3bM1m8zUtbwP/CVIbDc0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 799F93858299 for ; Wed, 14 Sep 2022 15:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 799F93858299 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-ekIEvRHsNXCr6QhL3SLIIA-1; Wed, 14 Sep 2022 11:08:59 -0400 X-MC-Unique: ekIEvRHsNXCr6QhL3SLIIA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A9A8F101A52A for ; Wed, 14 Sep 2022 15:08:59 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.40.192.189]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B36A40C2086; Wed, 14 Sep 2022 15:08:59 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 28EF8uxP1244445 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 17:08:56 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28EF8uQw1244444; Wed, 14 Sep 2022 17:08:56 +0200 To: GCC patches Subject: [COMMITTED] Minor fixes to frange. Date: Wed, 14 Sep 2022 17:08:48 +0200 Message-Id: <20220914150852.1244397-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743958375087112146?= X-GMAIL-MSGID: =?utf-8?q?1743958375087112146?= Following are a series of cleanups to the frange code in preparation for a much more invasive patch rewriting the NAN and sign tracking bits. Please be patient, as I'm trying to break everything up into small chunks instead of dropping a mondo patch removing the NAN and sign tristate handling. No functional changes. Regstrapped on x86-64 Linux, plus I ran selftests for -ffinite-math-only. gcc/ChangeLog: * value-query.cc (range_query::get_tree_range): Remove check for overflow. * value-range-pretty-print.cc (vrange_printer::visit): Move read of type until after undefined_p is checked. * value-range.cc (frange::set): Remove asserts for REAL_CST. (frange::contains_p): Tidy up. (range_tests_nan): Add comment. * value-range.h (frange::type): Check for undefined_p. (frange::set_undefined): Remove set of endpoints. --- gcc/value-query.cc | 3 --- gcc/value-range-pretty-print.cc | 3 +-- gcc/value-range.cc | 15 +++++---------- gcc/value-range.h | 3 +-- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/gcc/value-query.cc b/gcc/value-query.cc index ad80db780c2..de83f469be4 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -217,9 +217,6 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt) case REAL_CST: { - if (TREE_OVERFLOW_P (expr)) - expr = drop_tree_overflow (expr); - frange &f = as_a (r); f.set (expr, expr); diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc index 93e18d3c1b6..b124e46cb9e 100644 --- a/gcc/value-range-pretty-print.cc +++ b/gcc/value-range-pretty-print.cc @@ -122,14 +122,13 @@ vrange_printer::print_irange_bitmasks (const irange &r) const void vrange_printer::visit (const frange &r) const { - tree type = r.type (); - pp_string (pp, "[frange] "); if (r.undefined_p ()) { pp_string (pp, "UNDEFINED"); return; } + tree type = r.type (); dump_generic_node (pp, type, 0, TDF_NONE, false); pp_string (pp, " "); if (r.varying_p ()) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 6f0609959b3..d40a4ebf657 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -357,15 +357,11 @@ frange::set_signbit (fp_prop::kind k) void frange::set (tree min, tree max, value_range_kind kind) { - gcc_checking_assert (TREE_CODE (min) == REAL_CST); - gcc_checking_assert (TREE_CODE (max) == REAL_CST); - if (kind == VR_UNDEFINED) { set_undefined (); return; } - // Treat VR_ANTI_RANGE and VR_VARYING as varying. if (kind != VR_RANGE) { @@ -401,7 +397,6 @@ frange::set (tree min, tree max, value_range_kind kind) gcc_checking_assert (is_nan || tree_compare (LE_EXPR, min, max)); normalize_kind (); - if (flag_checking) verify_range (); } @@ -612,17 +607,17 @@ frange::operator== (const frange &src) const bool frange::contains_p (tree cst) const { + gcc_checking_assert (m_kind != VR_ANTI_RANGE); + const REAL_VALUE_TYPE *rv = TREE_REAL_CST_PTR (cst); + if (undefined_p ()) return false; if (varying_p ()) return true; - gcc_checking_assert (m_kind == VR_RANGE); - const REAL_VALUE_TYPE *rv = TREE_REAL_CST_PTR (cst); - if (real_compare (GE_EXPR, rv, &m_min) - && real_compare (LE_EXPR, rv, &m_max)) + if (real_compare (GE_EXPR, rv, &m_min) && real_compare (LE_EXPR, rv, &m_max)) { if (HONOR_SIGNED_ZEROS (m_type) && real_iszero (rv)) { @@ -3652,7 +3647,7 @@ range_tests_nan () ASSERT_FALSE (r0 == r0); ASSERT_TRUE (r0 != r0); - // [5,6] U NAN. + // [5,6] U NAN = [5,6] NAN. r0 = frange_float ("5", "6"); r0.set_nan (fp_prop::NO); r1 = frange_nan (float_type_node); diff --git a/gcc/value-range.h b/gcc/value-range.h index f9a01ee7a05..0ba0193bc1f 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -1141,6 +1141,7 @@ frange::frange (tree min, tree max, value_range_kind kind) inline tree frange::type () const { + gcc_checking_assert (!undefined_p ()); return m_type; } @@ -1160,8 +1161,6 @@ frange::set_undefined () m_kind = VR_UNDEFINED; m_type = NULL; m_props.set_undefined (); - memset (&m_min, 0, sizeof (m_min)); - memset (&m_max, 0, sizeof (m_max)); } // Set R to maximum representable value for TYPE.