summaryrefslogtreecommitdiff
path: root/gcc/cfgrtl.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-09 21:17:10 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-09 21:17:10 +0000
commit1f78217c0e58ddce6f65bded4733f117b83b23ad (patch)
treebc5b5a43fdbb93e7f4ab44c191121d39d27fa746 /gcc/cfgrtl.c
parent2ee50ac085a7522133cdd093b04fab0f2ae553e6 (diff)
downloadgcc-1f78217c0e58ddce6f65bded4733f117b83b23ad.tar.gz
PR rtl-optimization/64536
* cfgrtl.c (rtl_tidy_fallthru_edge): Handle removal of degenerate tablejumps. * gcc.dg/pr64536.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219405 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgrtl.c')
-rw-r--r--gcc/cfgrtl.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index fdaefa213f8..f20fa7a69a9 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -1796,6 +1796,24 @@ rtl_tidy_fallthru_edge (edge e)
&& (any_uncondjump_p (q)
|| single_succ_p (b)))
{
+ rtx label;
+ rtx_jump_table_data *table;
+
+ if (tablejump_p (q, &label, &table))
+ {
+ /* The label is likely mentioned in some instruction before
+ the tablejump and might not be DCEd, so turn it into
+ a note instead and move before the tablejump that is going to
+ be deleted. */
+ const char *name = LABEL_NAME (label);
+ PUT_CODE (label, NOTE);
+ NOTE_KIND (label) = NOTE_INSN_DELETED_LABEL;
+ NOTE_DELETED_LABEL_NAME (label) = name;
+ rtx_insn *lab = safe_as_a <rtx_insn *> (label);
+ reorder_insns (lab, lab, PREV_INSN (q));
+ delete_insn (table);
+ }
+
#ifdef HAVE_cc0
/* If this was a conditional jump, we need to also delete
the insn that set cc0. */