public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] cprop: Fix -fcompare-debug bug in constprop_register [PR100148] Date: Fri, 14 May 2021 14:56:37 +0000 (GMT) [thread overview] Message-ID: <20210514145637.A2D4F394C078@sourceware.org> (raw) https://gcc.gnu.org/g:0b5df85a952cac06c037e07b1f4668eda801862e commit 0b5df85a952cac06c037e07b1f4668eda801862e Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Apr 21 12:31:45 2021 +0200 cprop: Fix -fcompare-debug bug in constprop_register [PR100148] The following testcase shows different behavior between -g and -g0 in constprop_register, if a flags register setter is separated from a conditional jump using those flags with -g by a DEBUG_INSN. As it uses just NEXT_INSN, for -g it will look at the DEBUG_INSN which is not a conditional jump, while otherwise it would look at the conditional jump and call cprop_jump. 2021-04-21 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/100148 * cprop.c (constprop_register): Use next_nondebug_insn instead of NEXT_INSN. * g++.dg/opt/pr100148.C: New test. (cherry picked from commit 022f6ee3ad67ee30f62c8c2aeeb4156494f3284e) Diff: --- gcc/cprop.c | 8 +++++--- gcc/testsuite/g++.dg/opt/pr100148.C | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gcc/cprop.c b/gcc/cprop.c index e4df5092144..a10791878f7 100644 --- a/gcc/cprop.c +++ b/gcc/cprop.c @@ -1008,16 +1008,18 @@ static int constprop_register (rtx from, rtx src, rtx_insn *insn) { rtx sset; + rtx_insn *next_insn; /* Check for reg or cc0 setting instructions followed by conditional branch instructions first. */ if ((sset = single_set (insn)) != NULL - && NEXT_INSN (insn) - && any_condjump_p (NEXT_INSN (insn)) && onlyjump_p (NEXT_INSN (insn))) + && (next_insn = next_nondebug_insn (insn)) != NULL + && any_condjump_p (next_insn) + && onlyjump_p (next_insn)) { rtx dest = SET_DEST (sset); if ((REG_P (dest) || CC0_P (dest)) - && cprop_jump (BLOCK_FOR_INSN (insn), insn, NEXT_INSN (insn), + && cprop_jump (BLOCK_FOR_INSN (insn), insn, next_insn, from, src)) return 1; } diff --git a/gcc/testsuite/g++.dg/opt/pr100148.C b/gcc/testsuite/g++.dg/opt/pr100148.C new file mode 100644 index 00000000000..d038879b6b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr100148.C @@ -0,0 +1,27 @@ +// PR rtl-optimization/100148 +// { dg-do compile } +// { dg-options "-O2 -fno-dce -fno-tree-dce -fno-tree-dominator-opts -fno-tree-sink -fcompare-debug" } + +int i; +enum E { } e, ee; + +bool +baz (int) +{ + return ee; +} + +bool bar (); +bool a, b; + +void +foo () +{ + switch (ee) + { + case 0: + e = E (a ? : i); + case 1: + !(b || baz (0) && bar ()); + } +}
reply other threads:[~2021-05-14 14:56 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=20210514145637.A2D4F394C078@sourceware.org \ --to=jakub@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).