This is an archive of the discontinued LLVM Phabricator instance.

[CodeMoverUtils] Enhance isSafeToMoveBefore() when moving BBs
ClosedPublic

Authored by congzhe on Sep 23 2021, 7:07 PM.

Details

Summary

When moving an entire basic block BB before InsertPoint, currently we check for all instructions whether the operands dominates InsertPoint, however, this can be improved such that even an operand does not dominate InsertPoint, as long as it appears as a previous instruction in the same BB, it is safe to move.

Diff Detail

Event Timeline

congzhe created this revision.Sep 23 2021, 7:07 PM
congzhe requested review of this revision.Sep 23 2021, 7:07 PM
Whitney added inline comments.Sep 23 2021, 7:46 PM
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
348

Do you think this is more clear?
if (CheckForEntireBlock && I.getParent() == OpInst->getParent() && DT.dominates(OpInst, &I))

congzhe updated this revision to Diff 374717.Sep 23 2021, 8:18 PM
congzhe added inline comments.
llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
348

Thanks for the suggestion! It's definitely more clear. I updated the patch accordingly.

Whitney accepted this revision.Sep 23 2021, 9:02 PM
This revision is now accepted and ready to land.Sep 23 2021, 9:02 PM
This revision was landed with ongoing or failed builds.Sep 24 2021, 2:52 AM
This revision was automatically updated to reflect the committed changes.