Fix crash in TileLoops when redomap input array is also used in postlude#2442
Merged
Fix crash in TileLoops when redomap input array is also used in postlude#2442
Conversation
…de (issue #2467) Agent-Logs-Url: https://github.com/diku-dk/futhark/sessions/b0c0abd9-a04a-4762-8fa3-b64a25c635fb Co-authored-by: athas <55833+athas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix compiler crash after tiling
Fix crash in TileLoops when redomap input array is also used in postlude
May 5, 2026
Member
|
This is a pretty obvious fix, close to what I would have written myself. My only worry is whether it is too conservative, and would stop tiling in other cases. However, it seems clear to me that all cases caught by this check would previously result in invalid code. |
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.
mmBlkRegTilingproduces invalid IR when a SegMap contains two redomaps sharing an input array — the first redomap is tiled (its input slice goes intotab_inv_stmfor shared-memory loading), but the second redomap in the postlude still references that same slice variable, which no longer exists in the epilogue's scope.Changes
src/Futhark/Optimise/BlkRegTiling.hs— Added a guard inmatchesBlkRegTilethat returnsNothingif any key intab_inv_stm(tiled redomap inputs) is also free in the postlude code (code2'' <> code2). This causesmmBlkRegTilingto decline and fall through totileInKernelBody, which handles the case correctly by placing invariant prelude definitions in the outer kernel body where they remain in scope.tests/tiling/issue2467.fut— Regression test using a matrix multiply + entrywise divide pattern that triggers the two-redomap-sharing-an-input scenario:Previously this crashed with
Use of unknown variable as_transformed_row_...after the tile-loops pass.