This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Use VectorTransferLoweringPatterns in VectorToSCF
ClosedPublic

Authored by springerm on May 16 2021, 10:38 PM.

Details

Summary

VectorTransferLoweringPatterns can be enabled via a pass option. These additional patterns lower permutation maps to minor identity maps with broadcasting, if possible, allowing for more efficient vector load/stores. The option is deactivated by default.

Depends On D102566

Diff Detail

Event Timeline

springerm created this revision.May 16 2021, 10:38 PM
springerm requested review of this revision.May 16 2021, 10:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2021, 10:38 PM
springerm added inline comments.May 16 2021, 10:39 PM
mlir/lib/Dialect/Vector/VectorTransforms.cpp
3082–3084

I think this check is a bit simpler than the old code and does the same thing. Or am I missing some special case?

nicolasvasilache accepted this revision.May 17 2021, 8:11 AM
nicolasvasilache added inline comments.
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
1189

let's name this into a proper constant and avoid carrying a magic 2 around.

This revision is now accepted and ready to land.May 17 2021, 8:11 AM
ThomasRaoux added inline comments.May 17 2021, 8:11 PM
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
1188

The use of benefit looks a bit odd to me here. This isn't really a problem of cost model but more a phase ordering problem. we currently don't pick a phase ordering using benefit so far so that seems a bit weird to me. I think you could just apply the pattern separately before, would that not give the same result?

I mean something like:

 // First lower transfer ops.
 RewritePatternSet lowerTransferPatterns(getFunction().getContext());
 mlir::vector::populateVectorTransferLoweringPatterns(lowerTransferPatterns);
(void)applyPatternsAndFoldGreedily(getFunction(), std::move(lowerTransferPatterns));

RewritePatternSet patterns(getFunction().getContext());
populateVectorToSCFConversionPatterns(patterns, options);
(void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));

I'm also wondering if it really needs to be done in this pass or it could be something handled at the strategy level but I don't have all the context there so it may be better that way.

mlir/lib/Dialect/Vector/VectorTransforms.cpp
3082–3084

Yeah I think that works.

springerm updated this revision to Diff 346321.May 18 2021, 6:44 PM

address comments

springerm marked an inline comment as done.May 18 2021, 6:45 PM
springerm added inline comments.
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
1188

Right, that's how it should be done.

This revision was landed with ongoing or failed builds.May 18 2021, 10:46 PM
This revision was automatically updated to reflect the committed changes.
mlir/test/Dialect/Vector/vector-transfer-lowering-to-scf.mlir