summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2019-07-07 12:42:45 -0600
committerJeff Law <law@gcc.gnu.org>2019-07-07 12:42:45 -0600
commit0411f1d6cb283b68e85d41fae7601d6a3e0a9954 (patch)
treeeb2940b2938ff792279d79c7f0fa5a600d41d174 /gcc/tree-ssa-dom.c
parent6ce4dac81392bb6f144c34a06e9be157c20f31da (diff)
re PR tree-optimization/91090 (A suspicious code in tree-ssa-dom.c)
PR tree-optimization/91090 * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Fix logic error in handling of ranges to simplify switch statements. From-SVN: r273184
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index b0d56fcf3e3..17c852d5299 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -913,21 +913,26 @@ simplify_stmt_for_jump_threading (gimple *stmt,
find_case_label_range (switch_stmt, vr->min (), vr->max (), &i, &j);
+ /* Is there only one such label? */
if (i == j)
{
tree label = gimple_switch_label (switch_stmt, i);
tree singleton;
+ /* The i'th label will only be taken if the value range of the
+ operand is entirely within the bounds of this label. */
if (CASE_HIGH (label) != NULL_TREE
? (tree_int_cst_compare (CASE_LOW (label), vr->min ()) <= 0
&& tree_int_cst_compare (CASE_HIGH (label), vr->max ()) >= 0)
: (vr->singleton_p (&singleton)
&& tree_int_cst_equal (CASE_LOW (label), singleton)))
return label;
-
- if (i > j)
- return gimple_switch_label (switch_stmt, 0);
}
+
+ /* If there are no such labels, then the default label
+ will be taken. */
+ if (i > j)
+ return gimple_switch_label (switch_stmt, 0);
}
if (vr->kind () == VR_ANTI_RANGE)