This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Region/BranchOpInterface: Allow implicit type conversions along control-flow edges
ClosedPublic

Authored by Mogball on Mar 1 2022, 9:32 PM.

Details

Summary

RegionBranchOpInterface and BranchOpInterface are allowed to make implicit type conversions along control-flow edges. In effect, this adds an interface method, areTypesCompatible, to both interfaces, which should return whether the types of corresponding successor operands and block arguments are compatible. Users of the interfaces, here on forth, must be aware that types may mismatch, although current users (in MLIR core), are not affected by this change. By default, type equality is used.

async.execute already has unequal types along control-flow edges (!async.value<f32> vs. f32), but it opted out of calling RegionBranchOpInterface::verifyTypes in its verifier. That method has now been removed and RegionBranchOpInterface will verify types along control edges by default in its verifier.

Diff Detail

Event Timeline

Mogball created this revision.Mar 1 2022, 9:32 PM
Herald added a project: Restricted Project. · View Herald Transcript
Mogball requested review of this revision.Mar 1 2022, 9:32 PM
Mogball retitled this revision from [mlir] Region/BranchOpInterface: allow relaxing of type equality along edges to [mlir] Allow implicit type conversions along control-flow edges.Mar 1 2022, 11:30 PM
Mogball edited the summary of this revision. (Show Details)
rriddle accepted this revision.Mar 3 2022, 4:25 PM

I would change the title to be more specific in that this is just about the interfaces (you could already have implicit type changes if you wanted).

mlir/lib/Interfaces/ControlFlowInterfaces.cpp
53

Can you sink this down to where it is actually used?

mlir/test/Transforms/control-flow-sink.mlir
168

Why was this changed?

mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp
57

You should be able to just do index == 0.

Mogball retitled this revision from [mlir] Allow implicit type conversions along control-flow edges to [mlir] Region/BranchOpInterface: Allow implicit type conversions along control-flow edges.Mar 4 2022, 12:22 PM
Mogball updated this revision to Diff 413102.Mar 4 2022, 12:29 PM
Mogball marked 3 inline comments as done.

review comments

Mogball added inline comments.Mar 4 2022, 12:32 PM
mlir/test/Transforms/control-flow-sink.mlir
168

I was incorrectly using the test op in this test. It turns out that the control-flow semantics of the op according to the interface implementation is that all its operands are passed as block arguments to the then and else regions, and the operands to the yield of those regions are passed as block arguments to the join region (with no indication of which of the then and else regions are actually selected...)

This revision was not accepted when it landed; it landed in state Needs Review.Mar 4 2022, 12:33 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.