This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Conditional Branch Argument Propagation
ClosedPublic

Authored by wsmoses on May 1 2021, 9:10 PM.

Details

Summary

In an operation in the true/false dest of a branch,
one can assume that the operation itself was true/false if
only that edge can reach the operation.

Diff Detail

Event Timeline

wsmoses created this revision.May 1 2021, 9:10 PM
wsmoses requested review of this revision.May 1 2021, 9:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2021, 9:10 PM
rriddle requested changes to this revision.May 1 2021, 9:17 PM
rriddle added inline comments.
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
961

nit: Remove the mlir:: here and below.

966

Ideally this would be based on a DominanceInfo that gets passed in as this only works for local cases. Can you add a TODO/FIXME on this pattern for upgrading when we have access to a DominanceInfo here?

968
969–970

Do you need to create a new ConstantOp for every use? Can you just check to see if one has already been created?

970

Isn't there a rewriter.getBoolAttr?

980
981

Same comment here.

987

?

mlir/test/Dialect/Standard/canonicalize.mlir
315–316

Can you clean this up to check only what is necessary? We shouldn't be checking comments, blocks, etc. We should only need to check that constants get generated and those constants feed into the consumers. Any SSA values should also be using regex captures, and not the literal value from the printer.

This revision now requires changes to proceed.May 1 2021, 9:17 PM
wsmoses updated this revision to Diff 342217.May 1 2021, 9:55 PM

Remove extra mlir namespace

wsmoses updated this revision to Diff 342221.May 1 2021, 10:29 PM

Simplify test and address remaining comments

wsmoses updated this revision to Diff 342223.May 1 2021, 11:22 PM

Add comment stating this can be expanded later [as a todo]

ftynse accepted this revision.May 3 2021, 12:23 AM

LGTM with River's comments addressed.

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
989–1001

It would be nice to have this code factored out into a function, it's almost the same as above and the overall pattern looks useful.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 7 2021, 10:33 AM
This revision was automatically updated to reflect the committed changes.