Move and rename -memref-dataflow-opt: lib/Transforms -> lib/Affine/Dialect/Transforms

The -memref-dataflow-opt pass (lib/Transforms/MemRefDataFlowOpt.cpp) hasn’t been located at the right place from the start. A couple of things about it.

  1. The pass really works on affine ops on memrefs and also makes use of affine dependence information. This should ideally have been in lib/Dialect/Affine/Transforms like other affine passes there. It really doesn’t depend on on anything more than what other affine passes use.

  2. This pass really replaces subscripted affine memref accesses with scalars and is thus more accurately a scalar replacement pass. Besides store to load forwarding, it can eliminate redundant loads: in all these cases, subscripted memref accesses get replaced by (scalar) SSA values. It’s not really a memref dataflow analysis/opt which can be far more general.

I propose to move this under lib/Dialect/Affine/Transforms and rename it AffineScalarReplacement.cpp (-affine-scalrep). It’ll thus become part of MLIRAffineTransforms instead of MLIRTransforms.

1 Like

Looks good!