public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1354] ifcvt: Fix -fcompare-debug bug [PR100852]
@ 2021-06-10 7:30 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-06-10 7:30 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2d2ed777b23ab6503027039e0adbfe1162f52b2f
commit r12-1354-g2d2ed777b23ab6503027039e0adbfe1162f52b2f
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Jun 10 09:28:27 2021 +0200
ifcvt: Fix -fcompare-debug bug [PR100852]
The following testcase fails -fcompare-debug, because it is ifcvt optimized
into umin only with -g0 and not with -g - the function(s) use
prev_nonnote_insn, which without -g finds a real insn the code is looking
for, while with -g finds a DEBUG_INSN.
2021-06-10 Jakub Jelinek <jakub@redhat.com>
PR debug/100852
* ifcvt.c (noce_get_alt_condition, noce_try_abs): Use
prev_nonnote_nondebug_insn instead of prev_nonnote_insn.
* g++.dg/opt/pr100852.C: New test.
Diff:
---
gcc/ifcvt.c | 4 ++--
gcc/testsuite/g++.dg/opt/pr100852.C | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 6ee44cbada2..d086ce8f0b7 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2398,7 +2398,7 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
rtx_insn *prev_insn;
/* First, look to see if we put a constant in a register. */
- prev_insn = prev_nonnote_insn (if_info->cond_earliest);
+ prev_insn = prev_nonnote_nondebug_insn (if_info->cond_earliest);
if (prev_insn
&& BLOCK_FOR_INSN (prev_insn)
== BLOCK_FOR_INSN (if_info->cond_earliest)
@@ -2669,7 +2669,7 @@ noce_try_abs (struct noce_if_info *if_info)
if (REG_P (c))
{
rtx set;
- rtx_insn *insn = prev_nonnote_insn (earliest);
+ rtx_insn *insn = prev_nonnote_nondebug_insn (earliest);
if (insn
&& BLOCK_FOR_INSN (insn) == BLOCK_FOR_INSN (earliest)
&& (set = single_set (insn))
diff --git a/gcc/testsuite/g++.dg/opt/pr100852.C b/gcc/testsuite/g++.dg/opt/pr100852.C
new file mode 100644
index 00000000000..9d9a9f08f80
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr100852.C
@@ -0,0 +1,25 @@
+// PR debug/100852
+// { dg-do compile }
+// { dg-options "-Og -fif-conversion -fno-tree-ccp -fno-tree-copy-prop -fcompare-debug" }
+
+static inline int
+min (unsigned a, int b)
+{
+ return a < b ? a : b;
+}
+
+struct S { S (char); };
+
+static inline S
+foo (unsigned x)
+{
+ int h;
+ h += min (x * 4, h);
+ return h;
+}
+
+void
+bar ()
+{
+ foo (0);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-10 7:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 7:30 [gcc r12-1354] ifcvt: Fix -fcompare-debug bug [PR100852] Jakub Jelinek
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).