aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-predicate-analysis.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-09-05 14:22:51 +0200
committerRichard Biener <rguenther@suse.de>2022-09-05 15:15:03 +0200
commit178447296423ff7e1072621185438c45ab5b0a1d (patch)
treef146e3eee62f7e44a2eb856b900da4ed90776a8e /gcc/gimple-predicate-analysis.cc
parente9ea2688271bd0b4319bdfb1fc852169ab3cf076 (diff)
downloadgcc-178447296423ff7e1072621185438c45ab5b0a1d.zip
gcc-178447296423ff7e1072621185438c45ab5b0a1d.tar.gz
gcc-178447296423ff7e1072621185438c45ab5b0a1d.tar.bz2
Remove MAX_SWITCH_CASES limit
The following removes the MAX_SWITCH_CASES limit to fight quadraticness when looking up case labels from edges. Instead use the {start,end}_recording_case_labels facility for that. For it to be usable I've exported get_cases_for_edge from tree-cfg.cc. * tree-cfg.h (get_cases_for_edge): Declare. * tree-cfg.cc (get_cases_for_edge): Export. * tree-ssa-uninit.cc (execute_late_warn_uninitialized): Start and end recording case labels. * gimple-predicate-analysis.cc (MAX_SWITCH_CASES): Remove. (predicate::init_from_control_deps): Use get_cases_for_edge.
Diffstat (limited to 'gcc/gimple-predicate-analysis.cc')
-rw-r--r--gcc/gimple-predicate-analysis.cc24
1 files changed, 2 insertions, 22 deletions
diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index 6684aa6..681047d 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -52,10 +52,6 @@
#define MAX_NUM_CHAINS 8
#define MAX_CHAIN_LEN 5
-/* The limit for the number of switch cases when we do the linear search
- for the case corresponding to an edge. */
-#define MAX_SWITCH_CASES 40
-
/* Return true if X1 is the negation of X2. */
static inline bool
@@ -1751,28 +1747,12 @@ predicate::init_from_control_deps (const vec<edge> *dep_chains,
}
else if (gswitch *gs = dyn_cast<gswitch *> (cond_stmt))
{
- tree l = NULL_TREE;
/* Find the case label, but avoid quadratic behavior. */
- if (gimple_switch_num_labels (gs) <= MAX_SWITCH_CASES)
- for (unsigned idx = 0;
- idx < gimple_switch_num_labels (gs); ++idx)
- {
- tree tl = gimple_switch_label (gs, idx);
- if (e->dest == label_to_block (cfun, CASE_LABEL (tl)))
- {
- if (!l)
- l = tl;
- else
- {
- l = NULL_TREE;
- break;
- }
- }
- }
+ tree l = get_cases_for_edge (e, gs);
/* If more than one label reaches this block or the case
label doesn't have a contiguous range of values (like the
default one) fail. */
- if (!l || !CASE_LOW (l))
+ if (!l || CASE_CHAIN (l) || !CASE_LOW (l))
has_valid_pred = false;
else if (!CASE_HIGH (l)
|| operand_equal_p (CASE_LOW (l), CASE_HIGH (l)))