diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-04-21 12:31:45 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-04-21 12:31:45 +0200 |
commit | 022f6ee3ad67ee30f62c8c2aeeb4156494f3284e (patch) | |
tree | 72c8a4621724009714cea62bfcdc505f82f1b0b3 /gcc/cprop.c | |
parent | 021607e12cb9c40d0859b78490f44bb3f7da5812 (diff) | |
download | gcc-022f6ee3ad67ee30f62c8c2aeeb4156494f3284e.zip gcc-022f6ee3ad67ee30f62c8c2aeeb4156494f3284e.tar.gz gcc-022f6ee3ad67ee30f62c8c2aeeb4156494f3284e.tar.bz2 |
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.
Diffstat (limited to 'gcc/cprop.c')
-rw-r--r-- | gcc/cprop.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/cprop.c b/gcc/cprop.c index 73034ce..6f34f6b 100644 --- a/gcc/cprop.c +++ b/gcc/cprop.c @@ -1007,16 +1007,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; } |