public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1546] Add recomputation to outgoing_edge_range. Date: Thu, 17 Jun 2021 00:11:51 +0000 (GMT) [thread overview] Message-ID: <20210617001151.513EE3857404@sourceware.org> (raw) https://gcc.gnu.org/g:786188e8b8cab47cb31177c6f4ab1a1578a607c3 commit r12-1546-g786188e8b8cab47cb31177c6f4ab1a1578a607c3 Author: Andrew MacLeod <amacleod@redhat.com> Date: Wed Jun 16 18:08:03 2021 -0400 Add recomputation to outgoing_edge_range. The gori engine can calculate outgoing ranges for exported values. This change allows 1st degree recomputation. If a name is not exported from a block, but one of the ssa_names used directly in computing it is, then we can recompute the ssa_name on the edge using the edge values for its operands. * gimple-range-gori.cc (gori_compute::has_edge_range_p): Check with may_recompute_p. (gori_compute::may_recompute_p): New. (gori_compute::outgoing_edge_range_p): Perform recomputations. * gimple-range-gori.h (class gori_compute): Add prototype. Diff: --- gcc/gimple-range-gori.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++---- gcc/gimple-range-gori.h | 1 + 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 09dcd694319..647f4964769 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -972,16 +972,18 @@ gori_compute::compute_operand1_and_operand2_range (irange &r, r.intersect (op_range); return true; } -// Return TRUE if a range can be calcalated for NAME on edge E. +// Return TRUE if a range can be calculated or recomputed for NAME on edge E. bool gori_compute::has_edge_range_p (tree name, edge e) { - // If no edge is specified, check if NAME is an export on any edge. - if (!e) - return is_export_p (name); + // Check if NAME is an export or can be recomputed. + if (e) + return is_export_p (name, e->src) || may_recompute_p (name, e); - return is_export_p (name, e->src); + // If no edge is specified, check if NAME can have a range calculated + // on any edge. + return is_export_p (name) || may_recompute_p (name); } // Dump what is known to GORI computes to listing file F. @@ -992,6 +994,32 @@ gori_compute::dump (FILE *f) gori_map::dump (f); } +// Return TRUE if NAME can be recomputed on edge E. If any direct dependant +// is exported on edge E, it may change the computed value of NAME. + +bool +gori_compute::may_recompute_p (tree name, edge e) +{ + tree dep1 = depend1 (name); + tree dep2 = depend2 (name); + + // If the first dependency is not set, there is no recompuation. + if (!dep1) + return false; + + // Don't recalculate PHIs or statements with side_effects. + gimple *s = SSA_NAME_DEF_STMT (name); + if (is_a<gphi *> (s) || gimple_has_side_effects (s)) + return false; + + // If edge is specified, check if NAME can be recalculated on that edge. + if (e) + return ((is_export_p (dep1, e->src)) + || (dep2 && is_export_p (dep2, e->src))); + + return (is_export_p (dep1)) || (dep2 && is_export_p (dep2)); +} + // Calculate a range on edge E and return it in R. Try to evaluate a // range for NAME on this edge. Return FALSE if this is either not a // control edge or NAME is not defined by this edge. @@ -1026,6 +1054,27 @@ gori_compute::outgoing_edge_range_p (irange &r, edge e, tree name, return true; } } + // If NAME isn't exported, check if it can be recomputed. + else if (may_recompute_p (name, e)) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (name); + + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "recomputation attempt on edge %d->%d for ", + e->src->index, e->dest->index); + print_generic_expr (dump_file, name, TDF_SLIM); + } + // Simply calculate DEF_STMT on edge E usng the range query Q. + fold_range (r, def_stmt, e, &q); + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, " : Calculated :"); + r.dump (dump_file); + fputc ('\n', dump_file); + } + return true; + } return false; } diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h index 06f3b791359..6f187db08cb 100644 --- a/gcc/gimple-range-gori.h +++ b/gcc/gimple-range-gori.h @@ -157,6 +157,7 @@ public: bool has_edge_range_p (tree name, edge e = NULL); void dump (FILE *f); private: + bool may_recompute_p (tree name, edge e = NULL); bool compute_operand_range (irange &r, gimple *stmt, const irange &lhs, tree name, class fur_source &src); bool compute_operand_range_switch (irange &r, gswitch *s, const irange &lhs,
reply other threads:[~2021-06-17 0:11 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=20210617001151.513EE3857404@sourceware.org \ --to=amacleod@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).