[Mlir-commits] [mlir] [mlir][CSE] Eliminate redundant reads across dominating blocks (PR #218146)

lonely eagle llvmlistbot at llvm.org
Sat Aug 22 10:16:42 PDT 2026


linuxlonelyeagle wrote:

* As I understand it, this is fundamentally a read/write constraint issue. Here, we have two cases: Read-After-Read (RAR) with no intervening writes, and Write-After-Write (WAW) with no intervening reads. I think both cases can be handled together since their underlying logic is essentially the same. Therefore, instead of shoehorning this into CSE, it might make more sense to implement a standalone memory optimization pass dedicated to these eliminations.

* The implementation in this PR doesn't feel particularly clean to me (though to be fair, I've only skimmed through it). My understanding is that you simply need to update the MemEffectsCache continuously as you traverse from fromOp to nextOp—the key lies in how the cache is updated. When moving from fromOp to the next op, if that op contains regions, you should step into the region and check for writes. Once you hit a terminator op, you exit the region and resume traversal until you reach toOp.

https://github.com/llvm/llvm-project/pull/218146


More information about the Mlir-commits mailing list