This is an archive of the discontinued LLVM Phabricator instance.

Add narrow type emulation pattern for vector.transfer_read
ClosedPublic

Authored by yzhang93 on Aug 24 2023, 10:36 AM.

Diff Detail

Event Timeline

yzhang93 created this revision.Aug 24 2023, 10:36 AM
Herald added a project: Restricted Project. · View Herald Transcript
yzhang93 requested review of this revision.Aug 24 2023, 10:36 AM
mravishankar requested changes to this revision.Aug 26 2023, 1:45 PM

Mostly looks good to me. Some minor comments

mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
176

Better to move this create method after all the checks to avoid generating instructions for cases where failure is returned

201

This casting is strange. You can just do (origElements + scale - 1) / scale

210

Isn't this just origElements. Just use that instead of this.

This revision now requires changes to proceed.Aug 26 2023, 1:45 PM
yzhang93 requested review of this revision.Aug 28 2023, 2:46 PM
yzhang93 updated this revision to Diff 554058.
yzhang93 marked 2 inline comments as done.
yzhang93 added inline comments.Aug 28 2023, 2:47 PM
mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
210

Yes, the current assumption is vector.load/vector.transfer_read with an even number of elements, and it is just origElements. Not sure if there's a need to consider loading an odd number of elements in the real application. The current implementation will have error when loading an odd number of elements.

hanchung accepted this revision.Aug 28 2023, 3:05 PM
hanchung added inline comments.
mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
84

[optional] you can also use llvm::divideCeil. (note that (A+B-1)/B is okay to me because it is common.)

140

[optional] ditto

mravishankar accepted this revision.Aug 28 2023, 4:16 PM
mravishankar added inline comments.
mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
84

+1.

109

Nit: Rename to convertedSourceType or newSourceType to be consistent.

This revision is now accepted and ready to land.Aug 28 2023, 4:16 PM
yzhang93 updated this revision to Diff 554107.Aug 28 2023, 4:52 PM
This revision was automatically updated to reflect the committed changes.