This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow empty position in vector.insert and vector.extract
ClosedPublic

Authored by springerm on May 4 2021, 5:59 PM.

Details

Summary

Such ops are no-ops and are folded to their respective source/vector operand.

Depends On D101745

Diff Detail

Event Timeline

springerm created this revision.May 4 2021, 5:59 PM
springerm requested review of this revision.May 4 2021, 5:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2021, 5:59 PM

You rely on the folder to remove this, but would you mind adding some safety in the lowering code to LLVM (so that we don't get llvm.insertvalue %arg0, %arg1[] which will crash during lowering to LLVM IR)

mlir/lib/Dialect/Vector/VectorOps.cpp
1164

I think that form was used for the slightly longer folders. I would be perfectly okay inlining the two lines of code above in here. But if you like this style, I am okay with it too...

You rely on the folder to remove this, but would you mind adding some safety in the lowering code to LLVM (so that we don't get llvm.insertvalue %arg0, %arg1[] which will crash during lowering to LLVM IR)

I'd avoid relying on the folder having to run beforehand.
We can just special case the empty position when lowering to LLVM and replace by the source during conversion to LLVM (rather than assert, which is how I interpret "adding some safety").

We can just special case the empty position when lowering to LLVM and replace by the source during conversion to LLVM (rather than assert, which is how I interpret "adding some safety").

Exactly. Either not rewriting or sipmly dropping to source (as the folder does) in the rewriting is exactly the kind of safety I had in mind.
Folders usually run, but I think it is not proper design to fully rely that that have run (especially when code can crash)

springerm updated this revision to Diff 344242.May 10 2021, 5:31 PM

address comments

springerm marked an inline comment as done.May 10 2021, 5:38 PM

We can just special case the empty position when lowering to LLVM and replace by the source during conversion to LLVM (rather than assert, which is how I interpret "adding some safety").

Exactly. Either not rewriting or sipmly dropping to source (as the folder does) in the rewriting is exactly the kind of safety I had in mind.
Folders usually run, but I think it is not proper design to fully rely that that have run (especially when code can crash)

Done.

Btw, this commit was necessary for an earlier design of the ProgressiveVectorToSCF lowering. It's not needed in the current design anymore. I thought it may be useful to keep the commit anyway, to make the op more general, but if you think this doesn't really add anything, I can also abandon this commit.

springerm updated this revision to Diff 344256.May 10 2021, 5:46 PM

address changes

aartbik accepted this revision.May 11 2021, 10:05 AM

Let's keep it! I actually like having ops "generalize" to corner cases. Thanks for the change.

This revision is now accepted and ready to land.May 11 2021, 10:05 AM
nicolasvasilache accepted this revision.May 12 2021, 3:40 AM