This is an archive of the discontinued LLVM Phabricator instance.

[mlir][SCF] Add an scf.take_assumed_branch transform op.
ClosedPublic

Authored by nicolasvasilache on Apr 12 2023, 6:23 AM.

Details

Summary

Given an scf.if conditional, using this transformation is akin to injecting
user-specified information that it is always safe to execute only the specified
if or else branch.

This is achieved by just replacing the scf.if by the content of one of its
branches.

This is particularly useful for user-controlled rewriting of conditionals
that exist solely to guard against out-of-bounds behavior.

At the moment, no assume or assert operation is emitted as it is not always
desirable. In the future, this may be controlled by a dedicated attribute.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 6:23 AM
nicolasvasilache requested review of this revision.Apr 12 2023, 6:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 6:23 AM
qcolombet accepted this revision.Apr 12 2023, 6:42 AM

LGTM

mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp
255

Do you expect to use blockArgs anytime soon?

Put differently should we have this argument at all at this time?

This revision is now accepted and ready to land.Apr 12 2023, 6:42 AM
This revision was landed with ongoing or failed builds.Apr 12 2023, 8:51 AM
This revision was automatically updated to reflect the committed changes.