[Mlir-commits] [mlir] [memref] Simplify loads from reinterpret_cast of 1D contiguous memrefs (PR #188459)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Thu Mar 26 09:18:08 PDT 2026
================
@@ -195,6 +196,237 @@ struct CopyToScalarLoadAndStore : public OpRewritePattern<memref::CopyOp> {
}
};
+static bool isConstZero(Value v) { return matchPattern(v, m_Zero()); }
+
+static bool isPureRankReshape(memref::ReinterpretCastOp rc, memref::LoadOp op) {
----------------
banach-space wrote:
IIUC, the goal is to look at `memref.load` for which the source argument comes from `memref.reinterpret_cast`? So, in this example, `rc` could be retrieved from `op`?
I know that you are trying to avoid repeating `getDefininingOp`, but in this case I would make an exception and write this as follows:
```suggestion
static bool isLoadFromPureRankReshape(memref::LoadOp loadFromRC) {
auto rc = op.getMemRef().getDefiningOp<memref::ReinterpretCastOp>();
assert(rc && "Not a load from memref.reinterpet_cast!");
```
It will make the relationship between `op` and `rc` clearer.
https://github.com/llvm/llvm-project/pull/188459
More information about the Mlir-commits
mailing list