public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10391] tree-optimization/97953 - fix bougs range recorded by EVRP Date: Wed, 12 Jan 2022 08:53:43 +0000 (GMT) [thread overview] Message-ID: <20220112085343.6E3E7393A411@sourceware.org> (raw) https://gcc.gnu.org/g:d4e5ca668498a41af6417721be2ec69b2eac062e commit r10-10391-gd4e5ca668498a41af6417721be2ec69b2eac062e Author: Richard Biener <rguenther@suse.de> Date: Thu Nov 26 16:13:08 2020 +0100 tree-optimization/97953 - fix bougs range recorded by EVRP EVRP records some ranges from asserts into SSA_NAME_RANGE_INFO but fails to assert that the condition the range is derived from is always true after the SSA names definition. The patch implements the simplest post-dominance check, basic-block equality. 2020-11-26 Richard Biener <rguenther@suse.de> PR tree-optimization/97953 * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_incoming_edge): Make sure the condition post-dominates the SSA definition before recording into SSA_NAME_RANGE_INFO. * gcc.dg/pr97953.c: New testcase. (cherry picked from commit c76b3f9e83353a4cd437ca137c1fb835c9b5c21f) Diff: --- gcc/gimple-ssa-evrp-analyze.c | 6 +++++- gcc/testsuite/gcc.dg/pr97953.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c index 9f8ce5575a2..8389a58b00d 100644 --- a/gcc/gimple-ssa-evrp-analyze.c +++ b/gcc/gimple-ssa-evrp-analyze.c @@ -220,7 +220,11 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb) push_value_range (vrs[i].first, vrs[i].second); if (is_fallthru && m_update_global_ranges - && all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt)) + && all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt) + /* The condition must post-dominate the definition point. */ + && (SSA_NAME_IS_DEFAULT_DEF (vrs[i].first) + || (gimple_bb (SSA_NAME_DEF_STMT (vrs[i].first)) + == pred_e->src))) { set_ssa_range_info (vrs[i].first, vrs[i].second); maybe_set_nonzero_bits (pred_e, vrs[i].first); diff --git a/gcc/testsuite/gcc.dg/pr97953.c b/gcc/testsuite/gcc.dg/pr97953.c new file mode 100644 index 00000000000..6219619d67b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97953.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-fre" } */ + +int __attribute__((noipa)) +foo (int flag, int *p) +{ + int val = *p; + if (flag) + { + if (val != 1) + __builtin_unreachable (); + return 0; + } + int val2 = *p; + return val2 == 2; +} + +int main() +{ + int i = 2; + if (foo (0, &i) != 1) + __builtin_abort (); + return 0; +}
reply other threads:[~2022-01-12 8:53 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=20220112085343.6E3E7393A411@sourceware.org \ --to=rguenth@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).