[SimplifyCFG] Re-apply Relax restriction for folding unconditional branches
authorSerguei Katkov <serguei.katkov@azul.com>
Thu, 8 Feb 2018 07:16:29 +0000 (07:16 +0000)
committerSerguei Katkov <serguei.katkov@azul.com>
Thu, 8 Feb 2018 07:16:29 +0000 (07:16 +0000)
commit66182d6c3805d167bb8b19b2958b481c4b3eed56
tree888fb98882921ebde1c5a871ba42196c858c2ee3
parentd535c4d9d244171f94d1d83cdb2292b39577a5b0
[SimplifyCFG] Re-apply Relax restriction for folding unconditional branches

The commit rL308422 introduces a restriction for folding unconditional
branches. Specifically if empty block with unconditional branch leads to
header of the loop then elimination of this basic block is prohibited.
However it seems this condition is redundantly strict.
If elimination of this basic block does not introduce more back edges
then we can eliminate this block.

The patch implements this relax of restriction.

The test profile/Linux/counter_promo_nest.c in compiler-rt project
is updated to meet this change.

Reviewers: efriedma, mcrosier, pacxx, hsung, davidxl
Reviewed By: pacxx
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42691

llvm-svn: 324572
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/LoopUnroll/peel-loop.ll
llvm/test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll
llvm/test/Transforms/LoopUnswitch/infinite-loop.ll
llvm/test/Transforms/SimplifyCFG/UncondBranchToHeader.ll [new file with mode: 0644]