This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: BranchFolding: Merge identical blocks, even if they are short.
ClosedPublic

Authored by iteratee on Mar 31 2017, 5:39 PM.

Details

Reviewers
davidxl
Summary

Merge identical blocks when it doesn't reduce fallthrough. It is common for
the blocks created from critical edge splitting to be identical. We would like
to merge these blocks whenever doing so would not reduce fallthrough.

Diff Detail

Event Timeline

iteratee created this revision.Mar 31 2017, 5:39 PM
davidxl added inline comments.Apr 1 2017, 12:29 PM
lib/CodeGen/BranchFolding.cpp
604

This may have bad effect on block layout if tail dup can recover from it. For instance, when both MBB1 and MBB2 have fall through successors.

iteratee added inline comments.Apr 3 2017, 12:30 PM
lib/CodeGen/BranchFolding.cpp
604

Currently tail-duplication only copies instructions to the ends of blocks with unconditional jumps, so this won't conflict with tail-duplication.
I could add a check that at least one of the blocks can't fall through, then it would be future proof if we start copying blocks during layout.

iteratee updated this revision to Diff 94123.Apr 4 2017, 2:34 PM
iteratee edited the summary of this revision. (Show Details)

Now merge in a far more limited case, only if one of the blocks is missing a fallthrough in or out.
Also, only after layout so that we reliably know about fallthrough.

davidxl accepted this revision.Apr 4 2017, 9:09 PM

lgtm

This revision is now accepted and ready to land.Apr 4 2017, 9:09 PM
iteratee closed this revision.May 2 2017, 4:36 PM

Committed in rL299890