From patchwork Fri Apr 29 09:02:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 53339 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0F0AA3858010 for ; Fri, 29 Apr 2022 09:04:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F0AA3858010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651223065; bh=9hLOQ2+O9NpDq8Znyd+ZRlbifJkG4G9U95vCoXw2R48=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MsRRySQJS0Iba7LLfPJfmKfgLQvHF8lOh8oUB1lbm8Jc5bKbcr8X67cHqdg8yc105 9vO7t6lghmB9bTLD+mAx/EAObf0k2JU3l2y9TYCDj821rLpsLQ2jTsQdb1OmsChPos OUs4uZmjllbDFg8L4Lo9qbOUBUHpqs0sFg6z+02o= 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 99D003858407 for ; Fri, 29 Apr 2022 09:03:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99D003858407 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-250-Mktes-LmMqCp5OMj0JWBOQ-1; Fri, 29 Apr 2022 05:03:49 -0400 X-MC-Unique: Mktes-LmMqCp5OMj0JWBOQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3F83811E75 for ; Fri, 29 Apr 2022 09:03:48 +0000 (UTC) Received: from abulafia (unknown [10.39.192.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 576D140336A; Fri, 29 Apr 2022 09:03:48 +0000 (UTC) Received: from abulafia (localhost [127.0.0.1]) by abulafia (8.17.1/8.17.1) with ESMTPS id 23T93je2731282 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 29 Apr 2022 11:03:45 +0200 Received: (from aldyh@localhost) by abulafia (8.17.1/8.17.1/Submit) id 23T93jjn730759; Fri, 29 Apr 2022 11:03:45 +0200 To: GCC patches Subject: [COMMITTED] Make irange::intersect(wide_int, wide_int) private. Date: Fri, 29 Apr 2022 11:02:32 +0200 Message-Id: <20220429090236.718140-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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 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-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" [I will be committing a series of small, hopefully non-intrusive cleanups to trunk in preparation for work to be done later this cycle that will definitely be invasive ;-). If these changes turn out to be remotely problematic, I can revert them, but I'm trying to get them in early because I'm leaving on a 6 week paternity leave on May 9th and would prefer the wider testing before departing.] This method should have been private, and somehow seeped into the API. Tested and benchmarked on x86-64 Linux. gcc/ChangeLog: * gimple-range-cache.h (non_null_ref::adjust_range): Do not use irange::intersect (wide_int, wide_int). * gimple-range-fold.cc (adjust_pointer_diff_expr): Same. (adjust_imagpart_expr): Same. * value-range.h (irange::intersect (wide_int, wide_int)): Make private. --- gcc/gimple-range-cache.h | 6 ++++-- gcc/gimple-range-fold.cc | 6 +++--- gcc/value-range.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 589b649da26..a0244e4f6a4 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -64,8 +64,10 @@ non_null_ref::adjust_range (irange &r, tree name, basic_block bb, if (non_null_deref_p (name, bb, search_dom)) { // Remove zero from the range. - unsigned prec = TYPE_PRECISION (TREE_TYPE (name)); - r.intersect (wi::one (prec), wi::max_value (prec, UNSIGNED)); + gcc_checking_assert (TYPE_UNSIGNED (TREE_TYPE (name))); + int_range<2> nz; + nz.set_nonzero (TREE_TYPE (name)); + r.intersect (nz); return true; } return false; diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index dfacf6f14dc..3169e29b5de 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -362,7 +362,7 @@ adjust_pointer_diff_expr (irange &res, const gimple *diff_stmt) tree max = vrp_val_max (ptrdiff_type_node); unsigned prec = TYPE_PRECISION (TREE_TYPE (max)); wide_int wmaxm1 = wi::to_wide (max, prec) - 1; - res.intersect (wi::zero (prec), wmaxm1); + res.intersect (int_range<2> (TREE_TYPE (max), wi::zero (prec), wmaxm1)); } } @@ -403,8 +403,8 @@ adjust_imagpart_expr (irange &res, const gimple *stmt) tree cst = gimple_assign_rhs1 (def_stmt); if (TREE_CODE (cst) == COMPLEX_CST) { - wide_int imag = wi::to_wide (TREE_IMAGPART (cst)); - res.intersect (imag, imag); + int_range<2> imag (TREE_IMAGPART (cst), TREE_IMAGPART (cst)); + res.intersect (imag); } } } diff --git a/gcc/value-range.h b/gcc/value-range.h index d4cba22d540..fe7795b55a6 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -73,7 +73,6 @@ public: // In-place operators. void union_ (const irange &); void intersect (const irange &); - void intersect (const wide_int& lb, const wide_int& ub); void invert (); // Operator overloads. @@ -135,6 +134,7 @@ private: void irange_set_1bit_anti_range (tree, tree); bool varying_compatible_p () const; + void intersect (const wide_int& lb, const wide_int& ub); unsigned char m_num_ranges; unsigned char m_max_ranges; ENUM_BITFIELD(value_range_kind) m_kind : 8;