tensorflow / mlir

"Multi-Level Intermediate Representation" Compiler Infrastructure
1.74k stars 258 forks source link

[spirv] Add a pass to convert a sequence of composite insert to one composite construct #196

Open antiagainst opened 5 years ago

antiagainst commented 5 years ago

Sometimes we will see the following code pattern

%0 = spv.undef : vector<3xi32>
%1 = spv.CompositeInsert %val0 into %0 : vector<3xi32>
%2 = spv.CompositeInsert %val1 into %1 : vector<3xi32>
%3 = spv.CompositeInsert %val2 into %2 : vector<3xi32>

for composite types.

The above can be converted into a

%3 = spv.CompositeConstruct %val0, %val1, %val2 : vector<3xi32>

To simplify the code and remove undef.

antiagainst commented 5 years ago

https://github.com/google/clspv/blob/master/lib/RewriteInsertsPass.cpp in clspv can serve as an example.

denis0x0D commented 4 years ago

@antiagainst @MaheshRavishankar according to this task, CompositeInsert and CompositeConstruct are not implemented yet, does anyone work on adding this instructions or I can take it? Thanks!

antiagainst commented 4 years ago

SGTM. Please feel free to pick it up! Thanks! :)

denis0x0D commented 4 years ago

@antiagainst does anyone have plans for this task?

antiagainst commented 4 years ago

Hey @denis0x0D, I don't think so. Please feel free to take it if you are interested. :)

denis0x0D commented 4 years ago

@antiagainst thanks!