Scalrep pass expects the values in the given affine map are unique. But this expectation is not satisfied in case of the failure to eliminate redundant store operations before forwarding store to load. We should be able to eliminate all unused store operations before forwarding store to load in the scalrep pass to make sure the uniqueness of the value. This is the case reported in https://github.com/llvm/llvm-project/issues/59461.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
The crash at https://github.com/llvm/llvm-project/issues/59461 is a bug that's just hidden with this change. Unused store elimination is currently done after store-to-load forward because that way you have fewer stores to look at (this should significantly speed up things on large bodies). In any case, this doesn't fix the bug that caused the assertion in https://github.com/llvm/llvm-project/issues/59461 - the input to store-to-load forwarding there is still a valid one with those two stores.
As described here https://github.com/llvm/llvm-project/issues/59461#issuecomment-1372924955, this isn't the right fix; it only hides the issue. I should be able to post revisions to fix this later today.
This fixes the assertion from addAffineIfOpDomain: https://reviews.llvm.org/D141250
And https://reviews.llvm.org/D141255 fixes the scalrep crash exposed and produces the desired simplification.