diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-07-14 15:14:59 -0700 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-07-19 09:17:02 -0700 |
commit | a86d5eca6a11c25da4aff436f53589950641675f (patch) | |
tree | d7f649c59afcca23e5fe2b6e6c66c2b6a6527586 /gcc/gimple-fold.cc | |
parent | bf20b770d9aabb15faf2644b5e3106249cb175f3 (diff) | |
download | gcc-a86d5eca6a11c25da4aff436f53589950641675f.zip gcc-a86d5eca6a11c25da4aff436f53589950641675f.tar.gz gcc-a86d5eca6a11c25da4aff436f53589950641675f.tar.bz2 |
Add flow_sensitive_info_storage and use it in gimple-fold.
This adds flow_sensitive_info_storage and uses it in
maybe_fold_comparisons_from_match_pd as mentioned in
https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621817.html .
Since using it in maybe_fold_comparisons_from_match_pd was easy
and allowed me to test the storage earlier, I did it.
This also hides better how the flow sensitive information is
stored and only a single place needs to be updated if that
ever changes (again).
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
* gimple-fold.cc (fosa_unwind): Replace `vrange_storage *`
with flow_sensitive_info_storage.
(follow_outer_ssa_edges): Update how to save off the flow
sensitive info.
(maybe_fold_comparisons_from_match_pd): Update restoring
of flow sensitive info.
* tree-ssanames.cc (flow_sensitive_info_storage::save): New method.
(flow_sensitive_info_storage::restore): New method.
(flow_sensitive_info_storage::save_and_clear): New method.
(flow_sensitive_info_storage::clear_storage): New method.
* tree-ssanames.h (class flow_sensitive_info_storage): New class.
Diffstat (limited to 'gcc/gimple-fold.cc')
-rw-r--r-- | gcc/gimple-fold.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 4027ff7..de94efb 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -6947,7 +6947,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, } static basic_block fosa_bb; -static vec<std::pair<tree, vrange_storage *> > *fosa_unwind; +static vec<std::pair<tree, flow_sensitive_info_storage> > *fosa_unwind; static tree follow_outer_ssa_edges (tree val) { @@ -6967,14 +6967,11 @@ follow_outer_ssa_edges (tree val) || POINTER_TYPE_P (TREE_TYPE (val))) && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (val))) return NULL_TREE; + flow_sensitive_info_storage storage; + storage.save_and_clear (val); /* If the definition does not dominate fosa_bb temporarily reset flow-sensitive info. */ - if (val->ssa_name.info.range_info) - { - fosa_unwind->safe_push (std::make_pair - (val, val->ssa_name.info.range_info)); - val->ssa_name.info.range_info = NULL; - } + fosa_unwind->safe_push (std::make_pair (val, storage)); return val; } return val; @@ -7034,14 +7031,14 @@ maybe_fold_comparisons_from_match_pd (tree type, enum tree_code code, type, gimple_assign_lhs (stmt1), gimple_assign_lhs (stmt2)); fosa_bb = outer_cond_bb; - auto_vec<std::pair<tree, vrange_storage *>, 8> unwind_stack; + auto_vec<std::pair<tree, flow_sensitive_info_storage>, 8> unwind_stack; fosa_unwind = &unwind_stack; if (op.resimplify (NULL, (!outer_cond_bb ? follow_all_ssa_edges : follow_outer_ssa_edges))) { fosa_unwind = NULL; for (auto p : unwind_stack) - p.first->ssa_name.info.range_info = p.second; + p.second.restore (p.first); if (gimple_simplified_result_is_gimple_val (&op)) { tree res = op.ops[0]; @@ -7065,7 +7062,7 @@ maybe_fold_comparisons_from_match_pd (tree type, enum tree_code code, } fosa_unwind = NULL; for (auto p : unwind_stack) - p.first->ssa_name.info.range_info = p.second; + p.second.restore (p.first); return NULL_TREE; } |