This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][SPIRVToLLVM] Conversion for composite extract and insert
ClosedPublic

Authored by georgemitenkov on Sep 24 2020, 2:39 AM.

Details

Summary

A pattern to convert spv.CompositeInsert and spv.CompositeExtract.
In LLVM, there are 2 ops that correspond to each instruction depending
on the container type. If the container type is a vector type, then the result of
conversion is llvm.insertelement or llvm.extractelement. If the container
type is an aggregate type (i.e. struct, array), the result of conversion
is llvm.insertvalue or llvm.extractvalue.

Diff Detail

Event Timeline

georgemitenkov created this revision.Sep 24 2020, 2:39 AM
georgemitenkov requested review of this revision.Sep 24 2020, 2:39 AM
georgemitenkov edited the summary of this revision. (Show Details)Sep 24 2020, 2:56 AM
mravishankar requested changes to this revision.Sep 29 2020, 5:47 PM
mravishankar added inline comments.
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
242

Can we split this? THere doesnt seem to much overlap between extract and insert and separate methods might better.

251

If you do a dyn_cast, the value can be null. If you are not checking for the null value, you can just use cast<..> here.

260

Please split these as well. Actually I really dont see a need for these helper functions. You could just do this at the call site itself.

267

Same as above. Just use cast<..> if you are not checking for null value.

563

Similar to other comments above. Might just be cleaner to split this into two patterns. One for insert and other for extract. There is not much to share here.

This revision now requires changes to proceed.Sep 29 2020, 5:47 PM
georgemitenkov marked 5 inline comments as done.

Splitted the pattern into two and removed unnecessary helper functions.

mravishankar accepted this revision.Oct 5 2020, 9:51 PM
This revision is now accepted and ready to land.Oct 5 2020, 9:51 PM