Make rtl_split_edge work for jumps that fall through (PR72749)
authorSegher Boessenkool <segher@kernel.crashing.org>
Sun, 15 Jan 2017 17:06:00 +0000 (18:06 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Sun, 15 Jan 2017 17:06:00 +0000 (18:06 +0100)
If a jump always falls through but that cannot be optimised away, like
is the case with the PowerPC bdnz insn if its jump target is the same as
the fallthrough, sched gets confused if it schedules some instructions
from before that jump instruction to behind it: it splits the
fallthrough branch, but the jump target isn't updated, and things fall
apart as in the PR.  This patch fixes it.

The second patch fragment makes -fsched-verbose=N work for N>=4; the
currently scheduled fragment can now contain a label.  Everything else
seems to work fine with that.

PR target/72749
* cfgrtl.c (rtl_split_edge): Also patch jump insns that jump to the
fallthrough.
* haifa-sched.c (dump_insn_stream): Don't crash if there is a label
in the currently scheduled RTL fragment.

From-SVN: r244477

gcc/ChangeLog
gcc/cfgrtl.c
gcc/haifa-sched.c

index c689c58670c67f9aca625f57c9733dd9678a03f4..9d079732939004c53106cceb4ea7ac0fedfdbb44 100644 (file)
@@ -1,3 +1,11 @@
+2017-01-15  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       PR target/72749
+       * cfgrtl.c (rtl_split_edge): Also patch jump insns that jump to the
+       fallthrough.
+       * haifa-sched.c (dump_insn_stream): Don't crash if there is a label
+       in the currently scheduled RTL fragment.
+
 2017-01-15  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR rtl-optimization/78751
index bba4a99161a4b407e67ef5f2f8bb77b0a4836866..c7e355ec7d4d436a0af4bac4d56364fc37d02f4b 100644 (file)
@@ -1935,7 +1935,8 @@ rtl_split_edge (edge edge_in)
          if (last
              && JUMP_P (last)
              && edge_in->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
-             && extract_asm_operands (PATTERN (last)) != NULL_RTX
+             && (extract_asm_operands (PATTERN (last))
+                 || JUMP_LABEL (last) == before)
              && patch_jump_insn (last, before, bb))
            df_set_bb_dirty (edge_in->src);
        }
index 1b13e32d89882aba10dcc6244e5407ff4488b6b6..07de1bbbb2391954928d017889ef0aa679aa8d62 100644 (file)
@@ -6495,7 +6495,7 @@ dump_insn_stream (rtx_insn *head, rtx_insn *tail)
 
       if (sched_verbose >= 4)
        {
-         if (NOTE_P (insn) || recog_memoized (insn) < 0)
+         if (NOTE_P (insn) || LABEL_P (insn) || recog_memoized (insn) < 0)
            fprintf (sched_dump, "nothing");
          else
            print_reservation (sched_dump, insn);