This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf] Add getNumRegionInvocations to IfOp
ClosedPublic

Authored by Mogball on Dec 3 2021, 5:23 PM.

Details

Summary

Implements the RegionBranchOpInterface method getNumRegionInvocations to scf::IfOp so that, when the condition is constant, the number of region executions can be analyzed by NumberOfExecutions.

Diff Detail

Event Timeline

Mogball created this revision.Dec 3 2021, 5:23 PM
Mogball requested review of this revision.Dec 3 2021, 5:23 PM

Can you add some justification to the patch description?

Mogball updated this revision to Diff 392106.Dec 6 2021, 9:40 AM

Fixing the build and updating description

Mogball edited the summary of this revision. (Show Details)Dec 6 2021, 9:41 AM
jpienaar accepted this revision.Dec 14 2021, 6:19 AM

I don't this interfaces well, but this makes sense to me

mlir/unittests/Dialect/SCF/SCFOps.cpp
30

R"mlir( ? (Given we could then, as mentioned in chat, look at injecting some syntax highlighting)

51

EXPECT_EQ ? (Expect is preferred except where it isn't safe to continue if assertion failed)

This revision is now accepted and ready to land.Dec 14 2021, 6:19 AM
Mogball updated this revision to Diff 394470.Dec 14 2021, 10:48 PM
Mogball marked 2 inline comments as done.
Mogball edited the summary of this revision. (Show Details)

review comments

ftynse accepted this revision.Dec 15 2021, 1:28 AM
ftynse added a subscriber: ftynse.

Shouldn't we just expect that ifs with known conditions are canonicalized away? I.e., is this ever necessary?

Shouldn't we just expect that ifs with known conditions are canonicalized away? I.e., is this ever necessary?

It depends on how the interface gets used. If used in a speculative fashion, the provided operands are not necessarily the same as the current operands of the if. Some algorithm/analysis could ask "what would be the region invocations if these were the operands". Not entirely sure how much that applies in this situation, but it does for e.g. the branch interfaces (e.g. during constant propagation).

This revision was automatically updated to reflect the committed changes.