llvm-project/llvm/test/Transforms/CodeGenPrepare
Alina Sbirlea dfd14adeb0 Generalize MergeBlockIntoPredecessor. Replace uses of MergeBasicBlockIntoOnlyPred.
Summary:
Two utils methods have essentially the same functionality. This is an attempt to merge them into one.
1. lib/Transforms/Utils/Local.cpp : MergeBasicBlockIntoOnlyPred
2. lib/Transforms/Utils/BasicBlockUtils.cpp : MergeBlockIntoPredecessor

Prior to the patch:
1. MergeBasicBlockIntoOnlyPred
Updates either DomTree or DeferredDominance
Moves all instructions from Pred to BB, deletes Pred
Asserts BB has single predecessor
If address was taken, replace the block address with constant 1 (?)

2. MergeBlockIntoPredecessor
Updates DomTree, LoopInfo and MemoryDependenceResults
Moves all instruction from BB to Pred, deletes BB
Returns if doesn't have a single predecessor
Returns if BB's address was taken

After the patch:
Method 2. MergeBlockIntoPredecessor is attempting to become the new default:
Updates DomTree or DeferredDominance, and LoopInfo and MemoryDependenceResults
Moves all instruction from BB to Pred, deletes BB
Returns if doesn't have a single predecessor
Returns if BB's address was taken

Uses of MergeBasicBlockIntoOnlyPred that need to be replaced:

1. lib/Transforms/Scalar/LoopSimplifyCFG.cpp
Updated in this patch. No challenges.

2. lib/CodeGen/CodeGenPrepare.cpp
Updated in this patch.
  i. eliminateFallThrough is straightforward, but I added using a temporary array to avoid the iterator invalidation.
  ii. eliminateMostlyEmptyBlock(s) methods also now use a temporary array for blocks
Some interesting aspects:
  - Since Pred is not deleted (BB is), the entry block does not need updating.
  - The entry block was being updated with the deleted block in eliminateMostlyEmptyBlock. Added assert to make obvious that BB=SinglePred.
  - isMergingEmptyBlockProfitable assumes BB is the one to be deleted.
  - eliminateMostlyEmptyBlock(BB) does not delete BB on one path, it deletes its unique predecessor instead.
  - adding some test owner as subscribers for the interesting tests modified:
    test/CodeGen/X86/avx-cmp.ll
    test/CodeGen/AMDGPU/nested-loop-conditions.ll
    test/CodeGen/AMDGPU/si-annotate-cf.ll
    test/CodeGen/X86/hoist-spill.ll
    test/CodeGen/X86/2006-11-17-IllegalMove.ll

3. lib/Transforms/Scalar/JumpThreading.cpp
Not covered in this patch. It is the only use case using the DeferredDominance.
I would defer to Brian Rzycki to make this replacement.

Reviewers: chandlerc, spatel, davide, brzycki, bkramer, javed.absar

Subscribers: qcolombet, sanjoy, nemanjai, nhaehnle, jlebar, tpr, kbarton, RKSimon, wmi, arsenm, llvm-commits

Differential Revision: https://reviews.llvm.org/D48202

llvm-svn: 335183
2018-06-20 22:01:04 +00:00
..
AArch64 [CGP] Split large data structres to sink more GEPs 2018-05-10 18:27:36 +00:00
AMDGPU [AMDGPU] Switch to the new addr space mapping by default 2018-02-02 16:07:16 +00:00
ARM [CodeGenPrepare] Improve source and dest alignments of memory intrinsics independently 2018-01-31 17:24:53 +00:00
Mips [CodeGenPrepare] Check that erased sunken address are not reused 2017-11-24 16:45:28 +00:00
NVPTX [BypassSlowDivision] Improve our handling of divisions by constants 2017-12-04 19:21:58 +00:00
X86 Generalize MergeBlockIntoPredecessor. Replace uses of MergeBasicBlockIntoOnlyPred. 2018-06-20 22:01:04 +00:00
2008-11-24-RAUW-Self.ll
basic.ll Generalize MergeBlockIntoPredecessor. Replace uses of MergeBasicBlockIntoOnlyPred. 2018-06-20 22:01:04 +00:00
bitreverse-hang.ll
builtin-condition.ll Add address space mangling to lifetime intrinsics 2017-04-10 20:18:21 +00:00
crash-on-large-allocas.ll Add a test for r307754 2017-07-12 16:30:37 +00:00
dom-tree.ll
gep-unmerging.ll Unmerge GEPs to reduce register pressure on IndirectBr edges. 2017-09-11 17:52:08 +00:00
invariant.group.ll Dissallow non-empty metadata for invariant.group 2018-05-18 23:53:46 +00:00
nonintegral.ll [CodeGenPrepare] Don't create inttoptr for ni ptrs 2017-06-29 20:28:59 +00:00
overflow-intrinsics.ll
section-samplepgo.ll Restrict call metadata based hotness detection to Sample PGO mode 2017-05-11 23:18:05 +00:00
section.ll [PGO] Function section hotness prefix should look at all blocks 2017-12-20 17:53:10 +00:00
skip-merging-case-block.ll Revert "[CGP] Merge empty case blocks if no extra moves are added." 2017-10-27 00:35:18 +00:00
split-indirect-loop.ll [CodeGenPrepare] Fix crash due to an invalid CFG 2017-04-17 19:11:04 +00:00
statepoint-relocate.ll [CGP] Fix the rematerialization of gc.relocates 2017-08-17 05:48:30 +00:00