From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 03640385841E; Sat, 10 Jun 2023 00:33:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03640385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357230; bh=y26jlOnFghu220EDMdyHg+sLbwDm6NGLVYWWFjViKic=; h=From:To:Subject:Date:From; b=IMUy4i28yN6bJdaPsIqswdQoXT6vtUM9R2gpVWsfltNLJEoHX6xwLbKSBwhJB3s9t luMgLOA2B5f/SMoem9JPLC4CUuxc4ervrmu6YLVm9QUXfeBCJC923oxCtDX52bkH3E zuEHuktOIzhz8Sj1Jifi0K4v7Siv+0OL4UR7J6QU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Macleod To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1670] Unify LT_EXPR range operator X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: eb29c3e1fab9f985144fd4d63f5b86c039c459d0 X-Git-Newrev: 5b079541006f05e6bd0d50e8bb139120d519b9a5 Message-Id: <20230610003350.03640385841E@sourceware.org> Date: Sat, 10 Jun 2023 00:33:49 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5b079541006f05e6bd0d50e8bb139120d519b9a5 commit r14-1670-g5b079541006f05e6bd0d50e8bb139120d519b9a5 Author: Andrew MacLeod Date: Fri Jun 9 13:29:15 2023 -0400 Unify LT_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_lt): Remove. Move prototypes to range-op-mixed.h (operator_lt::fold_range): Rename from foperator_lt. (operator_lt::op1_range): Ditto. (float_table::float_table): Remove LT_EXPR. * range-op-mixed.h (class operator_lt): Combined from integer and float files. * range-op.cc (op_lt): New object. (unified_table::unified_table): Add LT_EXPR. (class operator_lt): Move to range-op-mixed.h. (lt_op1_op2_relation): Fold into operator_lt::op1_op2_relation. (integral_table::integral_table): Remove LT_EXPR. (pointer_table::pointer_table): Remove LT_EXPR. * range-op.h (lt_op1_op2_relation): Delete. Diff: --- gcc/range-op-float.cc | 52 +++++++++++++++------------------------------------ gcc/range-op-mixed.h | 30 +++++++++++++++++++++++++++++ gcc/range-op.cc | 39 ++++++++------------------------------ gcc/range-op.h | 1 - 4 files changed, 53 insertions(+), 69 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index ec24167a8c5..1b0ac9a7fc2 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -779,32 +779,10 @@ operator_not_equal::op1_range (frange &r, tree type, return true; } -class foperator_lt : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return lt_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio = TRIO_VARYING) const final override; -} fop_lt; - bool -foperator_lt::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_lt::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_LT)) return true; @@ -822,11 +800,11 @@ foperator_lt::fold_range (irange &r, tree type, } bool -foperator_lt::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_lt::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -859,11 +837,11 @@ foperator_lt::op1_range (frange &r, } bool -foperator_lt::op2_range (frange &r, - tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_lt::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1547,7 +1525,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_lt.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (LT_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2786,7 +2765,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (LT_EXPR, fop_lt); set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 03a988d9c8a..bc93ab5be06 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -141,4 +141,34 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_lt : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio = TRIO_VARYING) const final override; + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 1bea4af101d..13877999847 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -64,6 +64,7 @@ class unified_table : public range_op_table operator_equal op_equal; operator_not_equal op_not_equal; +operator_lt op_lt; // Invoke the initialization routines for each class of range. @@ -75,6 +76,7 @@ unified_table::unified_table () set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); + set (LT_EXPR, op_lt); } // The tables are hidden and accessed via a simple extern function. @@ -1090,34 +1092,17 @@ build_ge (irange &r, tree type, const wide_int &val) } -class operator_lt : public range_operator +void +operator_lt::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, LT_EXPR, lh, rh); } -} op_lt; + update_known_bitmask (r, LT_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -lt_op1_op2_relation (const irange &lhs) +operator_lt::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1132,12 +1117,6 @@ lt_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_lt::op1_op2_relation (const irange &lhs) const -{ - return lt_op1_op2_relation (lhs); -} - bool operator_lt::fold_range (irange &r, tree type, const irange &op1, @@ -4847,7 +4826,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); @@ -4899,7 +4877,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); diff --git a/gcc/range-op.h b/gcc/range-op.h index 8ab5f414147..df1d8871b53 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind lt_op1_op2_relation (const irange &lhs); relation_kind le_op1_op2_relation (const irange &lhs); relation_kind gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs);