This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][SCF] Simplify scf.if by swapping regions if condition is a not
ClosedPublic

Authored by wsmoses on Jan 10 2022, 7:29 PM.

Details

Summary

Given an if of the form, simplify it by eliminating the not and swapping the regions

scf.if not(c) {

yield origTrue

} else {

yield origFalse

}

becomes

scf.if c {

yield origFalse

} else {

yield origTrue

}

Diff Detail

Event Timeline

wsmoses created this revision.Jan 10 2022, 7:29 PM
wsmoses requested review of this revision.Jan 10 2022, 7:29 PM
ftynse added inline comments.Jan 11 2022, 1:35 AM
mlir/lib/Dialect/SCF/SCF.cpp
1205–1207

Can we early-return instead?

mehdi_amini accepted this revision.Jan 11 2022, 1:53 AM

LG with early return.

This revision is now accepted and ready to land.Jan 11 2022, 1:53 AM
wsmoses updated this revision to Diff 398989.Jan 11 2022, 9:36 AM

Address comments