https://gcc.gnu.org/g:09cb7c0e9dcab29232da92f1cc028454eec1c4c2
commit r17-557-g09cb7c0e9dcab29232da92f1cc028454eec1c4c2 Author: Andrew Pinski <[email protected]> Date: Fri May 15 14:40:52 2026 -0700 dom: small compile time optimization with switches In the process of converting gswitch away from CASE_LABEL_EXPR, I found a place in dom where we store the whole CASE_LABEL_EXPR. This place only needed to store the value of the case rather than the whole case expression. This does that small optimization and adds a few comments for the next person to understand what is going on here. It was not obvious at my first read of the code what it was doing or what error_mark was being used for. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-ssa-dom.cc (record_edge_info): For switches info only store the case low value to be recorded as the only value. Add comments. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/tree-ssa-dom.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc index 10a1c3f0b21a..3be7979f5289 100644 --- a/gcc/tree-ssa-dom.cc +++ b/gcc/tree-ssa-dom.cc @@ -524,6 +524,11 @@ record_edge_info (basic_block bb) { int i; int n_labels = gimple_switch_num_labels (switch_stmt); + /* info contains NULL, error_mark_node or a value. + error_mark signifies there are multiple values already. + A NULL signifies there it is uninitialized. + A value signifies that is the only value on that edge + to that bb. */ tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun)); for (i = 0; i < n_labels; i++) @@ -531,23 +536,27 @@ record_edge_info (basic_block bb) tree label = gimple_switch_label (switch_stmt, i); basic_block target_bb = label_to_block (cfun, CASE_LABEL (label)); + /* The default case is a case with multiple values. + If the value is already set then it has multiple values. */ if (CASE_HIGH (label) || !CASE_LOW (label) || info[target_bb->index]) info[target_bb->index] = error_mark_node; else - info[target_bb->index] = label; + /* Record the one value that can be on that edge to the + target_bb. */ + info[target_bb->index] = CASE_LOW (label); } FOR_EACH_EDGE (e, ei, bb->succs) { basic_block target_bb = e->dest; - tree label = info[target_bb->index]; + tree value = info[target_bb->index]; - if (label != NULL && label != error_mark_node) + if (value != NULL && value != error_mark_node) { tree x = fold_convert_loc (loc, TREE_TYPE (index), - CASE_LOW (label)); + value); edge_info = new class edge_info (e); edge_info->record_simple_equiv (index, x); }
