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-1137] Do not calculate new values when evaluating a debug statement. Date: Tue, 1 Jun 2021 01:32:04 +0000 (GMT) [thread overview] Message-ID: <20210601013204.C7A0F385E440@sourceware.org> (raw) https://gcc.gnu.org/g:715914d3f9e4e40af58d22103c7650cdd720ef92 commit r12-1137-g715914d3f9e4e40af58d22103c7650cdd720ef92 Author: Andrew MacLeod <amacleod@redhat.com> Date: Mon May 31 12:13:50 2021 -0400 Do not calculate new values when evaluating a debug statement. Add a flag to enable/disable immediately improving poor values found during cache propagation. Then disable it when processing debug statements. gcc/ PR tree-optimization/100781 * gimple-range-cache.cc (ranger_cache::ranger_cache): Enable new value calculation by default. (ranger_cache::enable_new_values): New. (ranger_cache::disable_new_values): New. (ranger_cache::push_poor_value): Check if new values are allowed. * gimple-range-cache.h (class ranger_cache): New member/methods. * gimple-range.cc (gimple_ranger::range_of_expr): Check for debug statement, and disable/renable new value calculation. gcc/testsuite/ PR tree-optimization/100781 * gcc.dg/pr100781.c: New. Diff: --- gcc/gimple-range-cache.cc | 20 ++++++++++++++++++++ gcc/gimple-range-cache.h | 3 +++ gcc/gimple-range.cc | 9 +++++++++ gcc/testsuite/gcc.dg/pr100781.c | 25 +++++++++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index dc32841310a..cc27574b7b4 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -586,6 +586,7 @@ ranger_cache::ranger_cache (gimple_ranger &q) : query (q) if (bb) m_gori.exports (bb); } + enable_new_values (); } ranger_cache::~ranger_cache () @@ -606,6 +607,23 @@ ranger_cache::dump (FILE *f) fprintf (f, "\n"); } +// Allow the cache to flag and query new values when propagation is forced +// to use an unknown value. + +void +ranger_cache::enable_new_values () +{ + m_new_value_p = true; +} + +// Disable new value querying. + +void +ranger_cache::disable_new_values () +{ + m_new_value_p = false; +} + // Dump the caches for basic block BB to file F. void @@ -689,6 +707,8 @@ ranger_cache::set_global_range (tree name, const irange &r) bool ranger_cache::push_poor_value (basic_block bb, tree name) { + if (!m_new_value_p) + return false; if (m_poor_value_list.length ()) { // Don't push anything else to the same block. If there are multiple diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index fee69bcc578..4af461d2aa3 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -100,6 +100,8 @@ public: bool get_non_stale_global_range (irange &r, tree name); void set_global_range (tree name, const irange &r); + void enable_new_values (); + void disable_new_values (); non_null_ref m_non_null; gori_compute m_gori; @@ -131,6 +133,7 @@ private: bool push_poor_value (basic_block bb, tree name); vec<update_record> m_poor_value_list; class gimple_ranger &query; + bool m_new_value_p; }; #endif // GCC_SSA_RANGE_CACHE_H diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index d58e151eb4e..ed0a0c9702b 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -971,6 +971,15 @@ gimple_ranger::range_of_expr (irange &r, tree expr, gimple *stmt) return true; } + // For a debug stmt, pick the best value currently available, do not + // trigger new value calculations. PR 100781. + if (is_gimple_debug (stmt)) + { + m_cache.disable_new_values (); + m_cache.range_of_expr (r, expr, stmt); + m_cache.enable_new_values (); + return true; + } basic_block bb = gimple_bb (stmt); gimple *def_stmt = SSA_NAME_DEF_STMT (expr); diff --git a/gcc/testsuite/gcc.dg/pr100781.c b/gcc/testsuite/gcc.dg/pr100781.c new file mode 100644 index 00000000000..c0e008a3ba5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr100781.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 --param=evrp-mode=ranger -fcompare-debug " } */ + +struct a { + int b; +}; +long c(short d, long e, struct a f) { +g:; + int h = f.b <= e, i = d, n = h >= d; + if (!n) + goto j; + goto k; +j:; + long l = 5; + if (l) + goto m; + d = 0; +m: + if (d) + return f.b; +k: + goto g; +} +int main() { } +
reply other threads:[~2021-06-01 1: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=20210601013204.C7A0F385E440@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).