public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r15-162] Implement operator_gt for prange. Date: Sat, 4 May 2024 08:29:09 +0000 (GMT) [thread overview] Message-ID: <20240504082909.9D5393846079@sourceware.org> (raw) https://gcc.gnu.org/g:76fae4051a72b2d417d50f1980dff8ab0c50d0c5 commit r15-162-g76fae4051a72b2d417d50f1980dff8ab0c50d0c5 Author: Aldy Hernandez <aldyh@redhat.com> Date: Wed Mar 20 11:10:03 2024 +0100 Implement operator_gt for prange. gcc/ChangeLog: * range-op-mixed.h: Add overloaded declarations for pointer variants. * range-op-ptr.cc (operator_gt::fold_range): New. (operator_gt::op1_range): New. (operator_gt::op2_range): New. (operator_gt::op1_op2_relation): New. (operator_gt::pointers_handled_p): New. Diff: --- gcc/range-op-mixed.h | 12 ++++++ gcc/range-op-ptr.cc | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 571729e2ab6..f7a07b19635 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -320,6 +320,9 @@ public: 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 prange &op1, const prange &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; @@ -327,6 +330,9 @@ public: bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, relation_trio = TRIO_VARYING) const final override; + bool op1_range (prange &r, tree type, + const irange &lhs, const prange &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; @@ -334,11 +340,16 @@ public: bool op2_range (irange &r, tree type, const irange &lhs, const irange &op1, relation_trio = TRIO_VARYING) const final override; + bool op2_range (prange &r, tree type, + const irange &lhs, const prange &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 irange &, const irange &) const final override; + relation_kind op1_op2_relation (const irange &lhs, const prange &, + const prange &) const final override; relation_kind op1_op2_relation (const irange &lhs, const frange &, const frange &) const final override; void update_bitmask (irange &r, const irange &lh, @@ -346,6 +357,7 @@ public: // Check op1 and op2 for compatibility. bool operand_check_p (tree, tree t1, tree t2) const final override { return range_compatible_p (t1, t2); } + bool pointers_handled_p (range_op_dispatch_type, unsigned) const final override; }; class operator_ge : public range_operator diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index eb28211b583..441a18c08c7 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -1747,6 +1747,112 @@ operator_le::pointers_handled_p (range_op_dispatch_type type, } } +bool +operator_gt::fold_range (irange &r, tree type, + const prange &op1, const prange &op2, + relation_trio rel) const +{ + if (relop_early_resolve (r, type, op1, op2, rel, VREL_GT)) + return true; + + signop sign = TYPE_SIGN (op1.type ()); + gcc_checking_assert (sign == TYPE_SIGN (op2.type ())); + + if (wi::gt_p (op1.lower_bound (), op2.upper_bound (), sign)) + r = range_true (); + else if (!wi::gt_p (op1.upper_bound (), op2.lower_bound (), sign)) + r = range_false (); + else + r = range_true_and_false (); + + //update_known_bitmask (r, GT_EXPR, op1, op2); + return true; +} + +bool +operator_gt::op1_range (prange &r, tree type, + const irange &lhs, const prange &op2, + relation_trio) const +{ + if (op2.undefined_p ()) + return false; + + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_gt (r, type, op2); + break; + + case BRS_FALSE: + build_le (r, type, op2); + break; + + default: + break; + } + return true; +} + +bool +operator_gt::op2_range (prange &r, tree type, + const irange &lhs, + const prange &op1, + relation_trio) const +{ + if (op1.undefined_p ()) + return false; + + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_lt (r, type, op1); + break; + + case BRS_FALSE: + build_ge (r, type, op1); + break; + + default: + break; + } + return true; +} + +relation_kind +operator_gt::op1_op2_relation (const irange &lhs, const prange &, + const prange &) const +{ + if (lhs.undefined_p ()) + return VREL_UNDEFINED; + + // FALSE = op1 > op2 indicates LE_EXPR. + if (lhs.zero_p ()) + return VREL_LE; + + // TRUE = op1 > op2 indicates GT_EXPR. + if (!range_includes_zero_p (lhs)) + return VREL_GT; + return VREL_VARYING; +} + +bool +operator_gt::pointers_handled_p (range_op_dispatch_type type, + unsigned dispatch) const +{ + switch (type) + { + case DISPATCH_FOLD_RANGE: + return dispatch == RO_IPP; + case DISPATCH_OP1_RANGE: + case DISPATCH_OP2_RANGE: + return dispatch == RO_PIP; + case DISPATCH_OP1_OP2_RELATION: + return dispatch == RO_IPP; + default: + return true; + } +} + // Initialize any pointer operators to the primary table void
reply other threads:[~2024-05-04 8:29 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240504082909.9D5393846079@sourceware.org \ --to=aldyh@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).