From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by sourceware.org (Postfix) with ESMTPS id 8E3673849ACC for ; Wed, 8 May 2024 06:12:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E3673849ACC Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=localhost.redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E3673849ACC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=207.211.30.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715148750; cv=none; b=NXtH8us2gzvPEHhWeTpHz7d4c35GTwGrS/Hz9tbDKJap2BMZUCyUsLhNV+D4dGYfwJ+wNsn8IvY9poAQcf+veBLc32teyh1dgt75vPkrENC4K4Ikt7xtEQdmj4lXMnE/8rRHv2JFNfvCnL9hzCnTIurVPysCkWOxH5bkJ27s+Og= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715148750; c=relaxed/simple; bh=HeDJEeP7SBJEYF3wZPneTS3LU1RldyZsiPVzVQsrj6E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lAmJwVHzSeSlx1ByIFbHdSxK+Q14EbyJQub0HXbGBqNctX/3PG+9UciVuLXeeTlovn13f9Uhn1DGx2Z7Mdvz5vfj/LrOyNamVqDOfwRqLI66M4LCzX6rrR9iIoPdeOaFvJsDK1TZLrMUW3ILNRABHqd4YJiLckShpHbfgrmg33c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715148748; 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: content-transfer-encoding:content-transfer-encoding; bh=8SgrtHKPlhUe4/ehci+Zc/sLlfQgGXuUs3H5UaqDbHQ=; b=K/8LqtTMaaarwInMtOUQddwVvjcxXi5+sJfvDibjhBlafyK8XtZUpm+jW7Qbd+YZN4g2jZ EaizcB60cYlyI/cOqJsiz0pIDDR+mcheBwHPXl+U+cUP0sTKwJD4YU4VMY6fxpxhYcqYA3 sE33+hyU4FgTi2Nx71Cw9nkHzItD65c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-467-Gy3qogBMPe6msdOMecWx-A-1; Wed, 08 May 2024 02:12:26 -0400 X-MC-Unique: Gy3qogBMPe6msdOMecWx-A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA03B101A52C for ; Wed, 8 May 2024 06:12:25 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AB64491020; Wed, 8 May 2024 06:12:25 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.18.1/8.17.1) with ESMTPS id 4486CMsb189208 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 8 May 2024 08:12:23 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.18.1/8.18.1/Submit) id 4486CMxA189207; Wed, 8 May 2024 08:12:22 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Enable prange support. Date: Wed, 8 May 2024 08:12:19 +0200 Message-ID: <20240508061221.189192-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; x-default=true X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NO_DNS_FOR_FROM,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: This throws the switch on prange. After this patch, it is no longer valid to store a pointer in an irange (or vice versa). Instead, they must go in prange, which is faster and more memory efficient. I will push this now, so I have time to do any follow-up bugfixing before going on paternity leave. There are various cleanups we plan on doing after this patch (faster intersect/union, remove range-op-mixed.h, remove value_range in favor of int_range_max, reclaim the name for the Value_Range temporary, clean up range-ops, etc etc). But we will hold off on those for now to make it easier to revert this patch, if for some reason we need to do so while I'm away. Tested on x86-64 Linux. gcc/ChangeLog: =09* gimple-range-cache.cc (sbr_sparse_bitmap::sbr_sparse_bitmap): =09Change irange to prange. =09* gimple-range-fold.cc (fold_using_range::fold_stmt): Same. =09(fold_using_range::range_of_address): Same. =09* gimple-range-fold.h (range_of_address): Same. =09* gimple-range-infer.cc (gimple_infer_range::add_nonzero): Same. =09* gimple-range-op.cc (class cfn_strlen): Same. =09* gimple-range-path.cc =09(path_range_query::adjust_for_non_null_uses): Same. =09* gimple-ssa-warn-access.cc (pass_waccess::check_pointer_uses): Same. =09* tree-ssa-structalias.cc (find_what_p_points_to): Same. =09* range-op-ptr.cc (range_op_table::initialize_pointer_ops): Remove =09hybrid entries in table. =09* range-op.cc (range_op_table::range_op_table): Add pointer =09entries for bitwise and/or and min/max. =09* value-range.cc (irange::verify_range): Add assert. =09* value-range.h (irange::varying_compatible_p): Remove check for =09error_mark_node. =09(irange::supports_p): Remove pointer support. =09* ipa-cp.h (ipa_supports_p): Add prange support. --- gcc/gimple-range-cache.cc | 4 ++-- gcc/gimple-range-fold.cc | 4 ++-- gcc/gimple-range-fold.h | 2 +- gcc/gimple-range-infer.cc | 2 +- gcc/gimple-range-op.cc | 2 +- gcc/gimple-range-path.cc | 2 +- gcc/gimple-ssa-warn-access.cc | 2 +- gcc/ipa-cp.h | 2 +- gcc/range-op-ptr.cc | 4 ---- gcc/range-op.cc | 18 ++++-------------- gcc/tree-ssa-structalias.cc | 2 +- gcc/value-range.cc | 1 + gcc/value-range.h | 4 ++-- 13 files changed, 18 insertions(+), 31 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 72ac2552311..bdd2832873a 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -274,10 +274,10 @@ sbr_sparse_bitmap::sbr_sparse_bitmap (tree t, vrange_= allocator *allocator, // Pre-cache zero and non-zero values for pointers. if (POINTER_TYPE_P (t)) { - int_range<2> nonzero; + prange nonzero; nonzero.set_nonzero (t); m_range[1] =3D m_range_allocator->clone (nonzero); - int_range<2> zero; + prange zero; zero.set_zero (t); m_range[2] =3D m_range_allocator->clone (zero); } diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 9c4ad1ee7b9..a9c8c4d03e6 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -597,7 +597,7 @@ fold_using_range::fold_stmt (vrange &r, gimple *s, fur_= source &src, tree name) // Process addresses. if (gimple_code (s) =3D=3D GIMPLE_ASSIGN && gimple_assign_rhs_code (s) =3D=3D ADDR_EXPR) - return range_of_address (as_a (r), s, src); + return range_of_address (as_a (r), s, src); =20 gimple_range_op_handler handler (s); if (handler) @@ -757,7 +757,7 @@ fold_using_range::range_of_range_op (vrange &r, // If a range cannot be calculated, set it to VARYING and return true. =20 bool -fold_using_range::range_of_address (irange &r, gimple *stmt, fur_source &s= rc) +fold_using_range::range_of_address (prange &r, gimple *stmt, fur_source &s= rc) { gcc_checking_assert (gimple_code (stmt) =3D=3D GIMPLE_ASSIGN); gcc_checking_assert (gimple_assign_rhs_code (stmt) =3D=3D ADDR_EXPR); diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h index 7cbe15d05e5..c7c599bfc93 100644 --- a/gcc/gimple-range-fold.h +++ b/gcc/gimple-range-fold.h @@ -157,7 +157,7 @@ protected: =09=09=09 fur_source &src); bool range_of_call (vrange &r, gcall *call, fur_source &src); bool range_of_cond_expr (vrange &r, gassign* cond, fur_source &src); - bool range_of_address (irange &r, gimple *s, fur_source &src); + bool range_of_address (prange &r, gimple *s, fur_source &src); bool range_of_phi (vrange &r, gphi *phi, fur_source &src); void range_of_ssa_name_with_loop_info (vrange &, tree, class loop *, gph= i *, =09=09=09=09=09 fur_source &src); diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc index c8e8b9b60ac..d5e1aa14275 100644 --- a/gcc/gimple-range-infer.cc +++ b/gcc/gimple-range-infer.cc @@ -123,7 +123,7 @@ gimple_infer_range::add_nonzero (tree name) { if (!gimple_range_ssa_p (name)) return; - int_range<2> nz; + prange nz; nz.set_nonzero (TREE_TYPE (name)); add_range (name, nz); } diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 55dfbb23ce2..ddd13ec5594 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -1120,7 +1120,7 @@ class cfn_strlen : public range_operator { public: using range_operator::fold_range; - virtual bool fold_range (irange &r, tree type, const irange &, + virtual bool fold_range (irange &r, tree type, const prange &, =09=09=09 const irange &, relation_trio) const { wide_int max =3D irange_val_max (ptrdiff_type_node); diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 96c6ac6b6a5..f1a12f76144 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -443,7 +443,7 @@ path_range_query::compute_ranges_in_block (basic_block = bb) void path_range_query::adjust_for_non_null_uses (basic_block bb) { - int_range_max r; + prange r; bitmap_iterator bi; unsigned i; =20 diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index 2c10d19e7f3..0cd5b6d6ef4 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -4213,7 +4213,7 @@ pass_waccess::check_pointer_uses (gimple *stmt, tree = ptr, =09=09 where the realloc call is known to have failed are valid. =09=09 Ignore pointers that nothing is known about. Those could =09=09 have escaped along with their nullness. */ -=09 value_range vr; +=09 prange vr; =09 if (m_ptr_qry.rvals->range_of_expr (vr, realloc_lhs, use_stmt)) =09=09{ =09=09 if (vr.zero_p ()) diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h index abeaaa4053e..e62a09f38af 100644 --- a/gcc/ipa-cp.h +++ b/gcc/ipa-cp.h @@ -296,7 +296,7 @@ bool values_equal_for_ipcp_p (tree x, tree y); static inline bool ipa_supports_p (tree type) { - return irange::supports_p (type); + return irange::supports_p (type) || prange::supports_p (type); } =20 #endif /* IPA_CP_H */ diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 466edc6bf74..4d5cbda764c 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -1968,8 +1968,4 @@ range_op_table::initialize_pointer_ops () { set (POINTER_PLUS_EXPR, op_pointer_plus); set (POINTER_DIFF_EXPR, op_pointer_diff); - set (BIT_AND_EXPR, op_hybrid_and); - set (BIT_IOR_EXPR, op_hybrid_or); - set (MIN_EXPR, op_hybrid_min); - set (MAX_EXPR, op_hybrid_max); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 65f3843227d..245385fe487 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -102,23 +102,13 @@ range_op_table::range_op_table () set (MINUS_EXPR, op_minus); set (NEGATE_EXPR, op_negate); set (MULT_EXPR, op_mult); - - // Occur in both integer and pointer tables, but currently share - // integral implementation. set (ADDR_EXPR, op_addr); set (BIT_NOT_EXPR, op_bitwise_not); set (BIT_XOR_EXPR, op_bitwise_xor); - - // These are in both integer and pointer tables, but pointer has a diffe= rent - // implementation. - // If commented out, there is a hybrid version in range-op-ptr.cc which - // is used until there is a pointer range class. Then we can simply - // uncomment the operator here and use the unified version. - - // set (BIT_AND_EXPR, op_bitwise_and); - // set (BIT_IOR_EXPR, op_bitwise_or); - // set (MIN_EXPR, op_min); - // set (MAX_EXPR, op_max); + set (BIT_AND_EXPR, op_bitwise_and); + set (BIT_IOR_EXPR, op_bitwise_or); + set (MIN_EXPR, op_min); + set (MAX_EXPR, op_max); } =20 // Instantiate a default range operator for opcodes with no entry. diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc index 9c63305063c..bb59c6a7c02 100644 --- a/gcc/tree-ssa-structalias.cc +++ b/gcc/tree-ssa-structalias.cc @@ -6833,7 +6833,7 @@ find_what_p_points_to (tree fndecl, tree p) struct ptr_info_def *pi; tree lookup_p =3D p; varinfo_t vi; - value_range vr; + prange vr; get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); bool nonnull =3D vr.nonzero_p (); =20 diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 3e1ecf69517..ada941bf3b5 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1518,6 +1518,7 @@ irange::verify_range () gcc_checking_assert (m_num_ranges =3D=3D 0); return; } + gcc_checking_assert (supports_p (type ())); gcc_checking_assert (m_num_ranges <=3D m_max_ranges); =20 // Legacy allowed these to represent VARYING for unknown types. diff --git a/gcc/value-range.h b/gcc/value-range.h index 6fe31d67582..6e24874c0a2 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -988,7 +988,7 @@ irange::varying_compatible_p () const const wide_int &u =3D m_base[1]; tree t =3D m_type; =20 - if (m_kind =3D=3D VR_VARYING && t =3D=3D error_mark_node) + if (m_kind =3D=3D VR_VARYING) return true; =20 unsigned prec =3D TYPE_PRECISION (t); @@ -1033,7 +1033,7 @@ irange::nonzero_p () const inline bool irange::supports_p (const_tree type) { - return INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type); + return INTEGRAL_TYPE_P (type); } =20 inline bool --=20 2.45.0