diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 98636cec8cfd6a7af66091f368617569bc1549ab..ec24167a8c5ea75b6400cc2851e2837902ad0bef 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -675,28 +675,10 @@ operator_equal::op1_range (frange &r, tree type, return true; } -class foperator_not_equal : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return not_equal_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; -} fop_not_equal; - bool -foperator_not_equal::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_not_equal::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_NE)) return true; @@ -750,10 +732,10 @@ foperator_not_equal::fold_range (irange &r, tree type, } bool -foperator_not_equal::op1_range (frange &r, tree type, - const irange &lhs, - const frange &op2, - relation_trio trio) const +operator_not_equal::op1_range (frange &r, tree type, + const irange &lhs, + const frange &op2, + relation_trio trio) const { relation_kind rel = trio.op1_op2 (); switch (get_bool_state (r, lhs, type)) @@ -2086,7 +2068,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_not_equal.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (NE_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. @@ -2803,7 +2786,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 (NE_EXPR, fop_not_equal); set (LT_EXPR, fop_lt); set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 79e2cbd8532ee4e904c3fb363383589c22f78ce5..03a988d9c8a34845fc463694224bc2bc412e73c2 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -112,4 +112,33 @@ public: const irange &rh) const final override; }; +class operator_not_equal : 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 rel = 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; + + 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 e85560a6ab50a449c0ca2ec14e069e5c6cc7a25d..1bea4af101dc4725f8441be4a095ca8943e552fa 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -63,6 +63,7 @@ class unified_table : public range_op_table // Instantiate the operators which apply to multiple types here. operator_equal op_equal; +operator_not_equal op_not_equal; // Invoke the initialization routines for each class of range. @@ -73,6 +74,7 @@ unified_table::unified_table () initialize_float_ops (); set (EQ_EXPR, op_equal); + set (NE_EXPR, op_not_equal); } // The tables are hidden and accessed via a simple extern function. @@ -926,34 +928,19 @@ operator_equal::op2_range (irange &r, tree type, return operator_equal::op1_range (r, type, lhs, op1, rel.swap_op1_op2 ()); } -class operator_not_equal : public range_operator +// ------------------------------------------------------------------------- + +void +operator_not_equal::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, NE_EXPR, lh, rh); } -} op_not_equal; + update_known_bitmask (r, NE_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -not_equal_op1_op2_relation (const irange &lhs) +operator_not_equal::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -968,12 +955,6 @@ not_equal_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_not_equal::op1_op2_relation (const irange &lhs) const -{ - return not_equal_op1_op2_relation (lhs); -} - bool operator_not_equal::fold_range (irange &r, tree type, const irange &op1, @@ -4866,7 +4847,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); @@ -4919,7 +4899,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); diff --git a/gcc/range-op.h b/gcc/range-op.h index 61f2ac16643bf853df788c37fd28d3fbe32f6901..8ab5f414147003b7563a434a494c20ee2cffd71c 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 not_equal_op1_op2_relation (const irange &lhs); 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);