diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-03 15:04:56 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-03 15:04:56 +0000 |
commit | 083ec7694129ea24e1ae55521fde42969b0c188f (patch) | |
tree | 6998589e82d54f69a3bea503f525a9ddeca7113a /gcc/stmt.c | |
parent | 7fddaaca9eccd9ef90301e281cfa97e455e206d5 (diff) | |
download | gcc-083ec7694129ea24e1ae55521fde42969b0c188f.tar.gz |
* stmt.c (expand_case): Speed up code to detect duplicate case
label targets and count unique case label targets.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90027 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r-- | gcc/stmt.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c index f9efbfee0b2..08dabdef1cf 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -2317,7 +2317,7 @@ expand_case (tree exp) { tree minval = NULL_TREE, maxval = NULL_TREE, range = NULL_TREE; rtx default_label = 0; - struct case_node *n, *m; + struct case_node *n; unsigned int count, uniq; rtx index; rtx table_label; @@ -2354,6 +2354,7 @@ expand_case (tree exp) if (index_type != error_mark_node) { tree elt; + bitmap label_bitmap; /* cleanup_tree_cfg removes all SWITCH_EXPR with their index expressions being INTEGER_CST. */ @@ -2392,6 +2393,7 @@ expand_case (tree exp) uniq = 0; count = 0; + label_bitmap = BITMAP_XMALLOC (); for (n = case_list; n; n = n->right) { /* Count the elements and track the largest and smallest @@ -2412,17 +2414,18 @@ expand_case (tree exp) if (! tree_int_cst_equal (n->low, n->high)) count++; - /* Count the number of unique case node targets. */ - uniq++; + /* If we have not seen this label yet, then increase the + number of unique case node targets seen. */ lab = label_rtx (n->code_label); - for (m = case_list; m != n; m = m->right) - if (label_rtx (m->code_label) == lab) - { - uniq--; - break; - } + if (!bitmap_bit_p (label_bitmap, CODE_LABEL_NUMBER (lab))) + { + bitmap_set_bit (label_bitmap, CODE_LABEL_NUMBER (lab)); + uniq++; + } } + BITMAP_XFREE (label_bitmap); + /* cleanup_tree_cfg removes all SWITCH_EXPR with a single destination, such as one with a default case only. */ gcc_assert (count != 0); |