[PATCH] Fix -fcompare-debug issue in cross-jumping (PR rtl-optimization/65980)
Jakub Jelinek
jakub@redhat.com
Mon Dec 14 20:15:00 GMT 2015
Hi!
rtx_renumbered_equal_p considers two LABEL_REFs equivalent if they
have the same next_real_insn, unfortunately next_real_insn doesn't ignore
debug insns. It ignores BARRIERs/JUMP_TABLE_DATA insns too, which is IMHO
not desirable either, so this patch uses next_nonnote_nondebug_insn instead
(which stops at CODE_LABEL) and keeps iterating if CODE_LABELs are found.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2015-12-14 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/65980
* jump.c (rtx_renumbered_equal_p) <case LABEL_REF>: Use
next_nonnote_nondebug_insn instead of next_real_insn and
skip over CODE_LABELs too.
* gcc.dg/pr65980.c: New test.
--- gcc/jump.c.jj 2015-11-04 11:12:18.000000000 +0100
+++ gcc/jump.c 2015-12-14 17:17:08.859741360 +0100
@@ -1802,8 +1802,16 @@ rtx_renumbered_equal_p (const_rtx x, con
/* Two label-refs are equivalent if they point at labels
in the same position in the instruction stream. */
- return (next_real_insn (LABEL_REF_LABEL (x))
- == next_real_insn (LABEL_REF_LABEL (y)));
+ else
+ {
+ rtx_insn *xi = next_nonnote_nondebug_insn (LABEL_REF_LABEL (x));
+ rtx_insn *yi = next_nonnote_nondebug_insn (LABEL_REF_LABEL (y));
+ while (xi && LABEL_P (xi))
+ xi = next_nonnote_nondebug_insn (xi);
+ while (yi && LABEL_P (yi))
+ yi = next_nonnote_nondebug_insn (yi);
+ return xi == yi;
+ }
case SYMBOL_REF:
return XSTR (x, 0) == XSTR (y, 0);
--- gcc/testsuite/gcc.dg/pr65980.c.jj 2015-12-14 17:07:54.398479666 +0100
+++ gcc/testsuite/gcc.dg/pr65980.c 2015-12-14 17:08:32.616950620 +0100
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/65980 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug" } */
+
+typedef struct { int b; } A;
+void (*a) (int);
+int b;
+
+int
+foo (A *v)
+{
+ asm goto ("" : : "m" (v->b) : : l);
+ return 0;
+l:
+ return 1;
+}
+
+int
+bar (void)
+{
+ if (b)
+ {
+ if (foo (0) && a)
+ a (0);
+ return 0;
+ }
+ if (foo (0) && a)
+ a (0);
+ return 0;
+}
Jakub
More information about the Gcc-patches
mailing list