Repository navigation
Prune consumed nodes and recompute mappings in fold legalization. - #5407
Draft
copybara-service[bot] wants to merge 1 commit into
Draft
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test_1019698616
branch
2 times, most recently
from
November 17, 2026 00:44
4a7958d to
6155541
Compare
copybara-service
Bot
force-pushed
the
test_1019698616
branch
from
November 17, 2026 02:41
6155541 to
b432e61
Compare
`ResourceSharingPass::LegalizeSequenceOfFolding` previously missed two
node-deletion cases enforced by `PerformFoldingActions`
(`renaming_done_by_previous_folding`): (1) a later fold whose destination was
already folded as a source was kept during legalization (poisoning its own
sources from subsequent legal folds) and then skipped at execution, and (2) a
node replaced via a prior fold's destination `EquivalenceMapping` remained
inside downstream folding batches, causing `PerformFoldingActions` to abort the
entire downstream batch rather than folding its remaining legal sources. In
addition, when sources were pruned during N-ary action construction or
legalization, pre-pruning mappings were retained (leaving stale destination
widenings) and `modified` remained `false` when a multi-source batch lost a
duplicate source.
- Track `consumed_nodes` (`{accepted sources} ∪ {accepted mapped destinations}`)
in `LegalizeSequenceOfFolding`: drop any fold targeting a consumed or
already-targeted destination, prune consumed sources from downstream batches,
and set `modified = true` whenever a fold or source is dropped.
- Recompute compatible N-ary `EquivalenceMapping`s via `eq_mapper` whenever a
fold loses sources in `MakeNaryFoldingAction` or `LegalizeSequenceOfFolding`.
- Require `eq_mapper` explicitly on `MakeNaryFoldingAction` and
`LegalizeSequenceOfFolding` rather than defaulting to the global equivalence
mapper.
PiperOrigin-RevId: 1019698616
copybara-service
Bot
force-pushed
the
test_1019698616
branch
from
November 17, 2026 17:59
b432e61 to
5f7bdcd
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prune consumed nodes and recompute mappings in fold legalization.
ResourceSharingPass::LegalizeSequenceOfFoldingpreviously missed twonode-deletion cases enforced by
PerformFoldingActions(
renaming_done_by_previous_folding): (1) a later fold whose destination wasalready folded as a source was kept during legalization (poisoning its own
sources from subsequent legal folds) and then skipped at execution, and (2) a
node replaced via a prior fold's destination
EquivalenceMappingremainedinside downstream folding batches, causing
PerformFoldingActionsto abort theentire downstream batch rather than folding its remaining legal sources. In
addition, when sources were pruned during N-ary action construction or
legalization, pre-pruning mappings were retained (leaving stale destination
widenings) and
modifiedremainedfalsewhen a multi-source batch lost aduplicate source.
consumed_nodes({accepted sources} ∪ {accepted mapped destinations})in
LegalizeSequenceOfFolding: drop any fold targeting a consumed oralready-targeted destination, prune consumed sources from downstream batches,
and set
modified = truewhenever a fold or source is dropped.EquivalenceMappings viaeq_mapperwhenever afold loses sources in
MakeNaryFoldingActionorLegalizeSequenceOfFolding.eq_mapperexplicitly onMakeNaryFoldingActionandLegalizeSequenceOfFoldingrather than defaulting to the global equivalencemapper.