This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf] Update IfOp to have getInvocationBounds
ClosedPublic

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

Details

Summary

This allows scf.if to be used by Control-Flow sink.

Depends on D115088

Diff Detail

Event Timeline

Mogball created this revision.Dec 3 2021, 5:25 PM
Mogball requested review of this revision.Dec 3 2021, 5:25 PM
Mogball updated this revision to Diff 392110.Dec 6 2021, 9:43 AM

Fix the build.

jpienaar added inline comments.Dec 6 2021, 10:53 AM
mlir/test/Transforms/control-flow-sink.mlir
140 ↗(On Diff #392110)

Could we make this change independent and independently tested from sinking?

Mogball added inline comments.Dec 6 2021, 11:58 AM
mlir/test/Transforms/control-flow-sink.mlir
140 ↗(On Diff #392110)

What do you mean? This diff depends on the sinking patch.

rriddle added inline comments.Dec 6 2021, 1:33 PM
mlir/test/Transforms/control-flow-sink.mlir
138–140 ↗(On Diff #392110)

This doesn't look like the right place for this. This file shouldn't contain test code for all possible dialects, the SCF/ folder should have a file testing control-flow-sink for its operations.

Mogball updated this revision to Diff 392439.Dec 7 2021, 9:26 AM

Move tests to test/Dialect/SCF

rriddle added inline comments.Dec 7 2021, 3:36 PM
mlir/test/Dialect/SCF/control-flow-sink.mlir
5

Can you fix up all of the raw SSA names? We shouldn't be using the names directly from the output, we should use FileCheck captures instead.

jpienaar added inline comments.Jan 11 2022, 7:50 AM
mlir/test/Transforms/control-flow-sink.mlir
140 ↗(On Diff #392110)

I meant in general, adding bound queries is not depend on sinking. It could be motivated, added and tested independently of sinking.

jpienaar added inline comments.Jan 11 2022, 8:00 AM
mlir/lib/Dialect/SCF/SCF.cpp
1196

Would BoolAttr work instead? (Given https://mlir.llvm.org/docs/Dialects/SCFDialect/#scfif-mlirscfifop it should be single bit integer here so would expect bool to work)

I see this is following the above, and almost exactly the same, could this be refactored into small helper?

mehdi_amini added inline comments.Jan 11 2022, 11:11 AM
mlir/lib/Dialect/SCF/SCF.cpp
1196

Do we even need this condition here?
If the condition is constant the if should be folded already.

Mogball updated this revision to Diff 401485.Jan 19 2022, 7:59 PM
Mogball marked 3 inline comments as done.

review comments

rriddle added inline comments.Jan 20 2022, 9:40 PM
mlir/lib/Dialect/SCF/SCF.cpp
1194

As mentioned in another comment I made somewhere, this is assuming we never call this method speculatively. Not that this is bad, but it is a specific invariant of the API that should be documented (on the interface doc itself).

Mogball added inline comments.Jan 24 2022, 3:41 PM
mlir/lib/Dialect/SCF/SCF.cpp
1194

Ah, right. I forgot about that

Mogball updated this revision to Diff 402709.Jan 24 2022, 4:07 PM

Add back the constant cond

Mogball marked an inline comment as done.Jan 24 2022, 5:29 PM
rriddle accepted this revision.Jan 26 2022, 10:15 PM
This revision is now accepted and ready to land.Jan 26 2022, 10:15 PM
This revision was automatically updated to reflect the committed changes.