summaryrefslogtreecommitdiff
path: root/gcc/gimple.c
diff options
context:
space:
mode:
authorppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>2016-08-04 18:11:08 +0000
committerppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>2016-08-04 18:11:08 +0000
commit88fe40622819e67a8094fb2ecaf3338db6a3a28b (patch)
tree8ee303ad04827e9a987b5e6b3b38386d5180a6c6 /gcc/gimple.c
parent93a3140013b2e5b135a363865cd8e165999d8cbd (diff)
downloadgcc-88fe40622819e67a8094fb2ecaf3338db6a3a28b.tar.gz
Designate the widest case label to be the default label
gcc/ChangeLog: * gimple.c (preprocess_case_label_vec_for_gimple): When the case labels are exhaustive, designate the label with the widest range to be the default label. gcc/testsuite/ChangeLog: * gcc.dg/switch-10.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239146 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r--gcc/gimple.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c
index e275dfc3c52..fc81e52e776 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2946,18 +2946,30 @@ preprocess_case_label_vec_for_gimple (vec<tree> labels,
high = CASE_LOW (labels[len - 1]);
if (tree_int_cst_equal (high, TYPE_MAX_VALUE (index_type)))
{
+ tree widest_label = labels[0];
for (i = 1; i < len; i++)
{
high = CASE_LOW (labels[i]);
low = CASE_HIGH (labels[i - 1]);
if (!low)
low = CASE_LOW (labels[i - 1]);
+
+ if (CASE_HIGH (labels[i]) != NULL_TREE
+ && (CASE_HIGH (widest_label) == NULL_TREE
+ || wi::gtu_p (wi::sub (CASE_HIGH (labels[i]),
+ CASE_LOW (labels[i])),
+ wi::sub (CASE_HIGH (widest_label),
+ CASE_LOW (widest_label)))))
+ widest_label = labels[i];
+
if (wi::add (low, 1) != high)
break;
}
if (i == len)
{
- tree label = CASE_LABEL (labels[0]);
+ /* Designate the label with the widest range to be the
+ default label. */
+ tree label = CASE_LABEL (widest_label);
default_case = build_case_label (NULL_TREE, NULL_TREE,
label);
}