Commit 0411f1d6 by Jeff Law Committed by Jeff Law

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
parent 6ce4dac8
2019-07-07 Jeff Law <law@redhat.com>
PR tree-optimization/91090
* tree-ssa-dom.c (simplify_stmt_for_jump_threading): Fix logic error
in handling of ranges to simplify switch statements.
2019-07-07 Iain Sandoe <iain@sandoe.co.uk> 2019-07-07 Iain Sandoe <iain@sandoe.co.uk>
* config/darwin.c (darwin_override_options): Make a final check on PIC * config/darwin.c (darwin_override_options): Make a final check on PIC
......
...@@ -913,21 +913,26 @@ simplify_stmt_for_jump_threading (gimple *stmt, ...@@ -913,21 +913,26 @@ simplify_stmt_for_jump_threading (gimple *stmt,
find_case_label_range (switch_stmt, vr->min (), vr->max (), &i, &j); find_case_label_range (switch_stmt, vr->min (), vr->max (), &i, &j);
/* Is there only one such label? */
if (i == j) if (i == j)
{ {
tree label = gimple_switch_label (switch_stmt, i); tree label = gimple_switch_label (switch_stmt, i);
tree singleton; 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 if (CASE_HIGH (label) != NULL_TREE
? (tree_int_cst_compare (CASE_LOW (label), vr->min ()) <= 0 ? (tree_int_cst_compare (CASE_LOW (label), vr->min ()) <= 0
&& tree_int_cst_compare (CASE_HIGH (label), vr->max ()) >= 0) && tree_int_cst_compare (CASE_HIGH (label), vr->max ()) >= 0)
: (vr->singleton_p (&singleton) : (vr->singleton_p (&singleton)
&& tree_int_cst_equal (CASE_LOW (label), singleton))) && tree_int_cst_equal (CASE_LOW (label), singleton)))
return label; 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) if (vr->kind () == VR_ANTI_RANGE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment