@@ -1028,9 +1028,41 @@ static t_rt_node* prune_route_tree_recurr(t_rt_node* node, CBRR& connections_inf
10281028 // 3. The node set is not active
10291029 //
10301030 // Then prune this node.
1031+ //
10311032 if (non_config_node_set_usage != nullptr && node_set != -1 && device_ctx.rr_switch_inf [node->parent_switch ].configurable () && (*non_config_node_set_usage)[node_set] == 0 ) {
10321033 // This node should be pruned, re-prune edges once more.
1033- return prune_route_tree_recurr (node, connections_inf, /* force_prune=*/ false , non_config_node_set_usage);
1034+ //
1035+ // If the following is true:
1036+ //
1037+ // - The node set is unused
1038+ // (e.g. (*non_config_node_set_usage)[node_set] == 0)
1039+ // - This particular node still had children
1040+ // (which is true by virtue of being in this else statement)
1041+ //
1042+ // Then that indicates that the node set became unused during the
1043+ // pruning. One or more of the children of this node will be
1044+ // pruned if prune_route_tree_recurr is called again, and
1045+ // eventually the whole node will be prunable.
1046+ //
1047+ // Consider the following graph:
1048+ //
1049+ // 1 -> 2
1050+ // 2 -> 3 [non-configurable]
1051+ // 2 -> 4 [non-configurable]
1052+ // 3 -> 5
1053+ // 4 -> 6
1054+ //
1055+ // Assume that nodes 5 and 6 do not connect to a sink, so they
1056+ // will be pruned (as normal). When prune_route_tree_recurr
1057+ // visits 2 for the first time, node 3 or 4 will remain. This is
1058+ // because when prune_route_tree_recurr visits 3 or 4, it will
1059+ // not have visited 4 or 3 (respectively). As a result, either
1060+ // node 3 or 4 will not be pruned on the first pass, because the
1061+ // node set usage count will be > 0. However after
1062+ // prune_route_tree_recurr visits 2, 3 and 4, the node set usage
1063+ // will be 0, so everything can be pruned.
1064+ return prune_route_tree_recurr (node, connections_inf,
1065+ /* force_prune=*/ false , non_config_node_set_usage);
10341066 }
10351067
10361068 // An unpruned intermediate node
0 commit comments