Skip to content

Hoist the shared dense load as a let in stage_strided_loads#8964

Merged
abadams merged 3 commits intomainfrom
abadams/stage_strided_loads_let
Mar 2, 2026
Merged

Hoist the shared dense load as a let in stage_strided_loads#8964
abadams merged 3 commits intomainfrom
abadams/stage_strided_loads_let

Conversation

@abadams
Copy link
Member

@abadams abadams commented Feb 25, 2026

Previously each strided load did the same dense load redundantly, and we relied on LLVM to dedup. Pulling it out as a let makes it possible in #8925 future to transpose it as one thing.

This will make it possible in future to transpose it as one thing.
Copy link
Member

@alexreinking alexreinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with a couple clarifying questions and one comment-wording nit.

replacer.replacements.emplace(std::make_pair(alloc, l), shuf);

// We can't lift the shared load further out than the scope over
// which the loads definition occur. If k.scope is null, the loads
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar here is awkward. "over which the load's definition occurs"? "the load is valid everywhere"?

return result;
}

bool can_hoist_shared_load(const IRNode *n, const std::string &buf, const Expr &idx) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any risk of hoisting past an extern stage with a side-effect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be. I'll try to construct a failure

Comment on lines +249 to +250
// within this stmt, and there are no stores to the given buffer in the
// stmt.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test that covers the "don't hoist past a store" mistake?

@alexreinking
Copy link
Member

Failure is #8928

Also address other review comments
@alexreinking
Copy link
Member

correctness_stage_strided_loads failure is real. I'm going to clear ccache on arm64-linux-worker-4

@abadams
Copy link
Member Author

abadams commented Mar 2, 2026

Failures unrelated

@abadams abadams merged commit 898f737 into main Mar 2, 2026
15 of 17 checks passed
@alexreinking alexreinking deleted the abadams/stage_strided_loads_let branch March 2, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants