This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Fix wrong Phi parent block for back-to-back loops
ClosedPublic

Authored by antiagainst on Apr 6 2020, 5:32 AM.

Details

Summary

If we have two back-to-back loops with block arguments, the OpPhi
instructions generated for the second loop's block arguments should
have use the merge block of the first SPIR-V loop structure as
their incoming parent block.

Diff Detail

Event Timeline

antiagainst created this revision.Apr 6 2020, 5:32 AM
Herald added a project: Restricted Project. · View Herald Transcript
mravishankar accepted this revision.Apr 7 2020, 9:13 AM
mravishankar added inline comments.
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
99

Just to clarify, this loop executes at most 1 iteration? If so can we avoid having a while loop? That makes it more confusing IMO

This revision is now accepted and ready to land.Apr 7 2020, 9:13 AM
antiagainst marked 2 inline comments as done.Apr 7 2020, 9:41 AM
antiagainst added inline comments.
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
99

Not necessary. This actually scans all previous ops before this loop op. For example, you can have the following:

spv.loop { ... } // loop1
spv.Load
spv.Bla
spv.Store
spv.loop { ... } // loop2

Here if loop2 has some block arguments that require phi nodes, the incoming parent block should be loop1's merge block. loop1 is multiple ops away so we need while loop here.

This revision was automatically updated to reflect the committed changes.
antiagainst marked an inline comment as done.