From c6bb413eeb9d13412e8101e3029099d7fd746708 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 1 Dec 2023 11:15:33 -0500 Subject: Use range_compatible_p in check_operands_p. Instead of directly checking type precision, check_operands_p should invoke range_compatible_p to keep the range checking centralized. * gimple-range-fold.h (range_compatible_p): Relocate. * value-range.h (range_compatible_p): Here. * range-op-mixed.h (operand_equal::operand_check_p): Call range_compatible_p rather than comparing precision. (operand_not_equal::operand_check_p): Ditto. (operand_not_lt::operand_check_p): Ditto. (operand_not_le::operand_check_p): Ditto. (operand_not_gt::operand_check_p): Ditto. (operand_not_ge::operand_check_p): Ditto. (operand_plus::operand_check_p): Ditto. (operand_abs::operand_check_p): Ditto. (operand_minus::operand_check_p): Ditto. (operand_negate::operand_check_p): Ditto. (operand_mult::operand_check_p): Ditto. (operand_bitwise_not::operand_check_p): Ditto. (operand_bitwise_xor::operand_check_p): Ditto. (operand_bitwise_and::operand_check_p): Ditto. (operand_bitwise_or::operand_check_p): Ditto. (operand_min::operand_check_p): Ditto. (operand_max::operand_check_p): Ditto. * range-op.cc (operand_lshift::operand_check_p): Ditto. (operand_rshift::operand_check_p): Ditto. (operand_logical_and::operand_check_p): Ditto. (operand_logical_or::operand_check_p): Ditto. (operand_logical_not::operand_check_p): Ditto. --- gcc/range-op.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'gcc/range-op.cc') diff --git a/gcc/range-op.cc b/gcc/range-op.cc index a091815..5dbc4bb 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2493,7 +2493,7 @@ public: { update_known_bitmask (r, LSHIFT_EXPR, lh, rh); } // Check compatibility of LHS and op1. bool operand_check_p (tree t1, tree t2, tree) const final override - { return TYPE_PRECISION (t1) == TYPE_PRECISION (t2); } + { return range_compatible_p (t1, t2); } } op_lshift; class operator_rshift : public cross_product_operator @@ -2525,7 +2525,7 @@ public: { update_known_bitmask (r, RSHIFT_EXPR, lh, rh); } // Check compatibility of LHS and op1. bool operand_check_p (tree t1, tree t2, tree) const final override - { return TYPE_PRECISION (t1) == TYPE_PRECISION (t2); } + { return range_compatible_p (t1, t2); } } op_rshift; @@ -3103,8 +3103,7 @@ public: relation_trio rel = TRIO_VARYING) const; // Check compatibility of all operands. bool operand_check_p (tree t1, tree t2, tree t3) const final override - { return (TYPE_PRECISION (t1) == TYPE_PRECISION (t2) - && TYPE_PRECISION (t1) == TYPE_PRECISION (t3)); } + { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); } } op_logical_and; bool @@ -3608,8 +3607,7 @@ public: relation_trio rel = TRIO_VARYING) const; // Check compatibility of all operands. bool operand_check_p (tree t1, tree t2, tree t3) const final override - { return (TYPE_PRECISION (t1) == TYPE_PRECISION (t2) - && TYPE_PRECISION (t1) == TYPE_PRECISION (t3)); } + { return range_compatible_p (t1, t2) && range_compatible_p (t1, t3); } } op_logical_or; bool @@ -4038,7 +4036,7 @@ public: relation_trio rel = TRIO_VARYING) const; // Check compatibility of LHS and op1. bool operand_check_p (tree t1, tree t2, tree) const final override - { return TYPE_PRECISION (t1) == TYPE_PRECISION (t2); } + { return range_compatible_p (t1, t2); } } op_logical_not; // Folding a logical NOT, oddly enough, involves doing nothing on the -- cgit v1.1