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 r12-4766] Improve backward threading with switches. Date: Thu, 28 Oct 2021 12:32:40 +0000 (GMT) [thread overview] Message-ID: <20211028123240.305403857802@sourceware.org> (raw) https://gcc.gnu.org/g:113dab2b9d511f3aadc30a6a921fc30bd5f93706 commit r12-4766-g113dab2b9d511f3aadc30a6a921fc30bd5f93706 Author: Aldy Hernandez <aldyh@redhat.com> Date: Thu Oct 28 11:44:13 2021 +0200 Improve backward threading with switches. We've been essentially using find_taken_edge_switch_expr() in the backward threader, but this is suboptimal because said function only works with singletons. VRP has a much smarter find_case_label_range that works with ranges. Tested on x86-64 Linux with: a) Bootstrap & regtests. b) Verifying we get more threads than before. c) Asserting that the new code catches everything the old one code caught (over a set of bootstrap .ii files). gcc/ChangeLog: * tree-ssa-threadbackward.c (back_threader::find_taken_edge_switch): Use find_case_label_range instead of find_taken_edge. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/vrp106.c: Adjust for threading. * gcc.dg/tree-ssa/vrp113.c: Same. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/vrp106.c | 4 ++-- gcc/testsuite/gcc.dg/tree-ssa/vrp113.c | 2 -- gcc/tree-ssa-threadbackward.c | 8 ++++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c index f25ea9c3826..dc5021a57b5 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c @@ -1,6 +1,6 @@ /* PR tree-optimization/18046 */ -/* { dg-options "-O2 -fdump-tree-vrp-thread1-details" } */ -/* { dg-final { scan-tree-dump-times "Threaded jump" 1 "vrp-thread1" } } */ +/* { dg-options "-O2 -fdump-tree-ethread-details" } */ +/* { dg-final { scan-tree-dump-times "Registering jump thread" 1 "ethread" } } */ /* During VRP we expect to thread the true arm of the conditional through the switch and to the BB that corresponds to the 7 ... 9 case label. */ extern void foo (void); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c index ab8d91e0f10..dfe4989d313 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c @@ -13,5 +13,3 @@ int f(int a) { case 7: return 19; } } - -/* { dg-final { scan-tree-dump "return 3;" "vrp1" { xfail *-*-* } } } */ diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 6c1b15904ce..456effca5e1 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -195,11 +195,11 @@ back_threader::find_taken_edge_switch (const vec<basic_block> &path, if (r.varying_p ()) return NULL; - tree val; - if (r.singleton_p (&val)) - return ::find_taken_edge (gimple_bb (sw), val); + tree label = find_case_label_range (sw, &r); + if (!label) + return NULL; - return NULL; + return find_edge (gimple_bb (sw), label_to_block (cfun, CASE_LABEL (label))); } // Same as find_taken_edge, but for paths ending in a GIMPLE_COND.
reply other threads:[~2021-10-28 12:32 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=20211028123240.305403857802@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).