https://gcc.gnu.org/g:80dea726c896e558ffee4036534f56698a2d412f
commit r16-4748-g80dea726c896e558ffee4036534f56698a2d412f Author: Michal Jires <[email protected]> Date: Mon Aug 25 17:58:03 2025 +0200 lto: Simplify control variable in loop of balanced partitioning Minor simplification as preparation for next patch. gcc/lto/ChangeLog: * lto-partition.cc (lto_balanced_map): Simplify. Diff: --- gcc/lto/lto-partition.cc | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc index c53471173dea..650bf638162d 100644 --- a/gcc/lto/lto-partition.cc +++ b/gcc/lto/lto-partition.cc @@ -1167,7 +1167,8 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) callgraph or IPA reference edge leaving the partition contributes into COST. Every edge inside partition was earlier computed as one leaving it and thus we need to subtract it from COST. */ - while (last_visited_node < lto_symtab_encoder_size (partition->encoder)) + for (; last_visited_node < lto_symtab_encoder_size (partition->encoder); + last_visited_node++) { int j; struct ipa_ref *ref = NULL; @@ -1178,9 +1179,6 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) { struct cgraph_edge *edge; - - last_visited_node++; - gcc_assert (node->definition || node->weakref); /* Compute boundary cost of callgraph edges. */ @@ -1197,8 +1195,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) gcc_assert (edge_cost > 0); index = lto_symtab_encoder_lookup (partition->encoder, edge->callee); - if (index != LCC_NOT_FOUND - && index < last_visited_node - 1) + if (index != LCC_NOT_FOUND && index < last_visited_node) cost -= edge_cost, internal += edge_cost; else cost += edge_cost; @@ -1216,15 +1213,12 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) gcc_assert (edge_cost > 0); index = lto_symtab_encoder_lookup (partition->encoder, edge->caller); - if (index != LCC_NOT_FOUND - && index < last_visited_node - 1) + if (index != LCC_NOT_FOUND && index < last_visited_node) cost -= edge_cost, internal += edge_cost; else cost += edge_cost; } } - else - last_visited_node++; /* Compute boundary cost of IPA REF edges and at the same time look into variables referenced from current partition and try to add them. */ @@ -1242,8 +1236,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) add_symbol_to_partition (partition, vnode); index = lto_symtab_encoder_lookup (partition->encoder, vnode); - if (index != LCC_NOT_FOUND - && index < last_visited_node - 1) + if (index != LCC_NOT_FOUND && index < last_visited_node) cost--, internal++; else cost++; @@ -1255,8 +1248,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) node = dyn_cast <cgraph_node *> (ref->referred); index = lto_symtab_encoder_lookup (partition->encoder, node); - if (index != LCC_NOT_FOUND - && index < last_visited_node - 1) + if (index != LCC_NOT_FOUND && index < last_visited_node) cost--, internal++; else cost++; @@ -1281,8 +1273,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) add_symbol_to_partition (partition, vnode); index = lto_symtab_encoder_lookup (partition->encoder, vnode); - if (index != LCC_NOT_FOUND - && index < last_visited_node - 1) + if (index != LCC_NOT_FOUND && index < last_visited_node) cost--, internal++; else cost++; @@ -1295,8 +1286,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) gcc_assert (node->definition); index = lto_symtab_encoder_lookup (partition->encoder, node); - if (index != LCC_NOT_FOUND - && index < last_visited_node - 1) + if (index != LCC_NOT_FOUND && index < last_visited_node) cost--, internal++; else cost++;
