This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Add vector.bitcast operation
ClosedPublic

Authored by ThomasRaoux on Aug 25 2020, 4:34 PM.

Details

Summary

Based on the RFC discussed here: https://llvm.discourse.group/t/rfc-vector-standard-add-bitcast-operation/1628/

Adding a vector.bitcast operation that allows casting to a vector of different element type. The most minor dimension bitwidth must stay unchanged.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Aug 25 2020, 4:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 4:34 PM
ThomasRaoux requested review of this revision.Aug 25 2020, 4:34 PM
mravishankar added inline comments.
mlir/lib/Dialect/Vector/VectorOps.cpp
2348

I think this is already captured by AnyTypeOf<[AnyVector]> ?

2351

You can add AllRanksMatch<["source", "result"]> to the op specification and have ODS generate this for you

ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/VectorOps.cpp
2348

Good point, removed it.

2351

That works, thanks!

mravishankar accepted this revision.Aug 25 2020, 9:45 PM

Looks good to me, but maybe wait for @aartbik to review.

This revision is now accepted and ready to land.Aug 25 2020, 9:45 PM
aartbik requested changes to this revision.Aug 26 2020, 10:06 AM
aartbik added inline comments.
mlir/include/mlir/Dialect/Vector/VectorOps.td
1530

just for my understanding, how is this different from AnyVector?

1538

I would remove this. In some cases, we can simply reinterpreted the data in the SIMD registers with a nop.

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

why not use the method getSourceVectorType() you introduced

2345

why not use the getResultVectorType()

2362

you don't seem to have tests for the folding

This revision now requires changes to proceed.Aug 26 2020, 10:06 AM

Address code review comments

ThomasRaoux marked 2 inline comments as done.Aug 26 2020, 12:36 PM

Thanks Aart. Please take another look.

mlir/include/mlir/Dialect/Vector/VectorOps.td
1530

It is strictly the same indeed. Changed it.

1538

I removed this line.

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

Added a test for this.

aartbik accepted this revision.Aug 26 2020, 1:30 PM
aartbik added inline comments.
mlir/test/Dialect/Vector/canonicalize.mlir
379

why not just A:.*

This revision is now accepted and ready to land.Aug 26 2020, 1:30 PM
ThomasRaoux marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.