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 r13-2876] Set ranges from unreachable edges for all known ranges. Date: Mon, 26 Sep 2022 14:42:34 +0000 (GMT) [thread overview] Message-ID: <20220926144234.3F1643858D37@sourceware.org> (raw) https://gcc.gnu.org/g:2460f7cdef7ef9c971de79271afc0db73687a272 commit r13-2876-g2460f7cdef7ef9c971de79271afc0db73687a272 Author: Aldy Hernandez <aldyh@redhat.com> Date: Fri Sep 23 19:47:33 2022 +0200 Set ranges from unreachable edges for all known ranges. In the conversion of DOM+evrp to DOM+ranger, we missed that evrp was exporting ranges for unreachable edges for all SSA names for which we have ranges for. Instead we have only been exporting ranges for the SSA name in the final conditional to the BB involving the unreachable edge. This patch adjusts adjusts DOM to iterate over the exports, similarly to what evrp was doing. Note that I also noticed that we don't calculate the nonzero bit mask for op1, when 0 = op1 & MASK. This isn't needed for this PR, since maybe_set_nonzero_bits() is chasing the definition and parsing the bitwise and on its own. However, I'll be adding the functionality for completeness sake, plus we could probably drop the maybe_set_nonzero_bits legacy call entirely. PR tree-optimization/107009 gcc/ChangeLog: * tree-ssa-dom.cc (dom_opt_dom_walker::set_global_ranges_from_unreachable_edges): Iterate over exports. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107009.c: New test. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/pr107009.c | 15 ++++++++++++++ gcc/tree-ssa-dom.cc | 35 ++++++++++++++++---------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr107009.c b/gcc/testsuite/gcc.dg/tree-ssa/pr107009.c new file mode 100644 index 00000000000..5010aed1723 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr107009.c @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-dom2-alias" } + +typedef __SIZE_TYPE__ size_t; + +void saxpy(size_t n) +{ + if (n == 0 || n % 8 != 0) + __builtin_unreachable(); + + extern void foobar (size_t n); + foobar (n); +} + +// { dg-final { scan-tree-dump "NONZERO.*fff8" "dom2" } } diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc index 513e0c88254..84bef798f52 100644 --- a/gcc/tree-ssa-dom.cc +++ b/gcc/tree-ssa-dom.cc @@ -1227,29 +1227,30 @@ void dom_opt_dom_walker::set_global_ranges_from_unreachable_edges (basic_block bb) { edge pred_e = single_pred_edge_ignoring_loop_edges (bb, false); - if (!pred_e) return; gimple *stmt = last_stmt (pred_e->src); + if (!stmt + || gimple_code (stmt) != GIMPLE_COND + || !assert_unreachable_fallthru_edge_p (pred_e)) + return; + tree name; - if (stmt - && gimple_code (stmt) == GIMPLE_COND - && (name = gimple_cond_lhs (stmt)) - && TREE_CODE (name) == SSA_NAME - && assert_unreachable_fallthru_edge_p (pred_e) - && all_uses_feed_or_dominated_by_stmt (name, stmt)) - { - Value_Range r (TREE_TYPE (name)); + gori_compute &gori = m_ranger->gori (); + FOR_EACH_GORI_EXPORT_NAME (gori, pred_e->src, name) + if (all_uses_feed_or_dominated_by_stmt (name, stmt)) + { + Value_Range r (TREE_TYPE (name)); - if (m_ranger->range_on_edge (r, pred_e, name) - && !r.varying_p () - && !r.undefined_p ()) - { - set_range_info (name, r); - maybe_set_nonzero_bits (pred_e, name); - } - } + if (m_ranger->range_on_edge (r, pred_e, name) + && !r.varying_p () + && !r.undefined_p ()) + { + set_range_info (name, r); + maybe_set_nonzero_bits (pred_e, name); + } + } } /* Record any equivalences created by the incoming edge to BB into
reply other threads:[~2022-09-26 14:42 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=20220926144234.3F1643858D37@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).