This is an archive of the discontinued LLVM Phabricator instance.

[CodeMoverUtils][WIP] Isolate checks strictly related to the code motion candidate instruction
AcceptedPublic

Authored by RithikSharma on Jun 22 2020, 5:08 AM.

Details

Summary

Some checks in isSafeToMoveBefore are independent of insert point, this patch isolate those checks and also adds some trivial checks from LICM. This is a work in progress until we move all the conservative insert point independent checks here from LICM.

Diff Detail

Event Timeline

RithikSharma created this revision.Jun 22 2020, 5:08 AM
RithikSharma marked an inline comment as done.Jun 22 2020, 6:25 AM
RithikSharma added inline comments.
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
308

These conditions are inherited from LICM, is this a generalized safe assumption? Is there any very obvious exception to this?

bmahjour added inline comments.Jun 22 2020, 11:22 AM
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
313

why do we start allowing terminators as safe candidates for code motion? Has this constraint been moved to another place that doesn't show up in this patch? The same question applies to checking for isa<PHINode>(InsertPoint) above.

Whitney added inline comments.Jun 22 2020, 12:01 PM
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
308

Not sure how this list is generated in LICM. Is it trying to exclude PHINode and terminators (e.g. BranchInst, SwitchInst, ...)? If so, then those was excluded in isSafeToMoveBefore originally.
Any test cases failed without this check?

323

This is covered in line 380.

Whitney marked an inline comment as done.Jun 22 2020, 12:05 PM
Whitney added inline comments.
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
313

Type of instructions are limited using isSafeToMove.

RithikSharma marked 2 inline comments as done.Jun 23 2020, 9:06 AM
RithikSharma added inline comments.
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
308

No failing test case yet and it does reflect the old TermInst and PHINode checks so it seems okay to me to keep this.

323

Thanks, that check is dependent on DT. I can remove this from here but I'll wait until we decide on keeping DT and PDT as optional argument as then we may end up missing this check. (I'll also look into other such checks if we decide to make DT and PDT optional).

Whitney added inline comments.Jun 26 2020, 12:58 PM
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
323

I see that you are moving a subset of checks from LICM over here, how is this set of checks selected from LICM?

asbirlea accepted this revision.Jun 29 2020, 12:09 PM
asbirlea added a subscriber: asbirlea.

Looks like a reasonable cleanup making safety checks reusable.
Please run check-all to check the statistics you're changing are not checked for in unit tests.

This revision is now accepted and ready to land.Jun 29 2020, 12:09 PM
Whitney accepted this revision.Jun 29 2020, 2:22 PM