llvm-project/llvm/lib/Transforms/Scalar
Anna Thomas 53c8d95c85 [Loop Deletion] Delete loops that are never executed
Summary:
Currently, loop deletion deletes loop where the only values
that are used outside the loop are loop-invariant.
This patch adds logic to delete loops where the loop is proven to be
never executed (i.e. the only predecessor of the loop preheader has a
constant conditional branch as terminator, and the preheader is not the
taken target). This will remove loops that become dead after
loop-unswitching generates constant conditional branches.

The next steps are:
1. moving the loop deletion implementation to LoopUtils.
2. Add logic in loop-simplifyCFG which will support changing conditional
constant branches to unconditional branches. If loops become unreachable in this
process, they can be removed using `deleteDeadLoop` function.

Reviewers: chandlerc, efriedma, sanjoy, reames

Reviewed by: sanjoy

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 302015
2017-05-03 11:47:11 +00:00
..
ADCE.cpp [ADCE] Remove redundent code [NFC] 2017-03-16 03:59:23 +00:00
AlignmentFromAssumptions.cpp [PH] Replace uses of AssertingVH from members of analysis results with 2017-01-24 12:55:57 +00:00
BDCE.cpp [PM] Introduce an analysis set used to preserve all analyses over 2017-01-15 06:32:49 +00:00
CMakeLists.txt [PM/LoopUnswitch] Introduce a new, simpler loop unswitch pass. 2017-04-27 18:45:20 +00:00
ConstantHoisting.cpp [ConstHoisting] Add BFI in constanthoisting pass and select the best insertion 2017-04-21 15:50:16 +00:00
ConstantProp.cpp Don't remove side effecting instructions due to ConstantFoldInstruction 2016-07-22 04:54:44 +00:00
CorrelatedValuePropagation.cpp Kill off the old SimplifyInstruction API by converting remaining users. 2017-04-28 19:55:38 +00:00
DCE.cpp [PM] Introduce an analysis set used to preserve all analyses over 2017-01-15 06:32:49 +00:00
DeadStoreElimination.cpp Cleanup in preparation for D30703. NFCI 2017-03-29 14:42:27 +00:00
EarlyCSE.cpp Kill off the old SimplifyInstruction API by converting remaining users. 2017-04-28 19:55:38 +00:00
FlattenCFGPass.cpp
Float2Int.cpp [PM] Introduce an analysis set used to preserve all analyses over 2017-01-15 06:32:49 +00:00
GVN.cpp Kill off the old SimplifyInstruction API by converting remaining users. 2017-04-28 19:55:38 +00:00
GVNHoist.cpp [GVNHoist] Mark GlobalsAA as preserved by GVNHoist. 2017-04-18 13:25:49 +00:00
GuardWidening.cpp [ValueTracking] Introduce a KnownBits struct to wrap the two APInts for computeKnownBits 2017-04-26 16:39:58 +00:00
IVUsersPrinter.cpp [PM] Separate the LoopAnalysisManager from the LoopPassManager and move 2017-01-11 09:43:56 +00:00
IndVarSimplify.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
InductiveRangeCheckElimination.cpp [IRCE] Add a missing invariant check 2017-02-07 23:59:07 +00:00
InferAddressSpaces.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
JumpThreading.cpp Take indirect branch into account as well when folding. 2017-05-01 17:15:37 +00:00
LICM.cpp Revert "Compute safety information in a much finer granularity." 2017-04-24 18:25:07 +00:00
LLVMBuild.txt
LoadCombine.cpp [LoadCombine] Avoid analysing dead basic blocks 2017-04-12 08:07:55 +00:00
LoopAccessAnalysisPrinter.cpp [PM] Separate the LoopAnalysisManager from the LoopPassManager and move 2017-01-11 09:43:56 +00:00
LoopDataPrefetch.cpp Revert @llvm.assume with operator bundles (r289755-r289757) 2016-12-19 08:22:17 +00:00
LoopDeletion.cpp [Loop Deletion] Delete loops that are never executed 2017-05-03 11:47:11 +00:00
LoopDistribute.cpp Add a wrapper around copy_if in STLExtras; NFC 2017-02-21 00:38:44 +00:00
LoopIdiomRecognize.cpp Empty Space. NFC 2017-05-01 23:08:19 +00:00
LoopInstSimplify.cpp Kill off the old SimplifyInstruction API by converting remaining users. 2017-04-28 19:55:38 +00:00
LoopInterchange.cpp Remove inclusion of SSAUpdater from several passes. 2017-01-29 01:55:24 +00:00
LoopLoadElimination.cpp Add a getPointerOperandType() helper to LoadInst and StoreInst; NFC 2017-04-18 22:00:54 +00:00
LoopPassManager.cpp [PM] Teach LoopUnroll to update the LPM infrastructure as it unrolls 2017-01-25 02:49:01 +00:00
LoopPredication.cpp Loop predication expand both sides of the widened condition 2017-02-27 15:44:49 +00:00
LoopRerollPass.cpp [LoopReroll] Prefer hasNUses/hasNUses or more as they're cheaper. NFCI. 2017-04-18 21:42:21 +00:00
LoopRotation.cpp LoopRotate: Fix use after scope bug 2017-04-28 22:05:55 +00:00
LoopSimplifyCFG.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
LoopSink.cpp [PM] Port LoopSink to the new pass manager. 2017-01-20 08:42:19 +00:00
LoopStrengthReduce.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
LoopUnrollPass.cpp [IR] Redesign the case iterator in SwitchInst to actually be an iterator 2017-04-12 07:27:28 +00:00
LoopUnswitch.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
LoopVersioningLICM.cpp [LoopVersioning] Require loop-simplify form for loop versioning. 2016-12-19 17:13:37 +00:00
LowerAtomic.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
LowerExpectIntrinsic.cpp [IR] Redesign the case iterator in SwitchInst to actually be an iterator 2017-04-12 07:27:28 +00:00
LowerGuardIntrinsic.cpp [PM] Port LowerGuardIntrinsic to the new PM. 2016-07-28 22:08:41 +00:00
MemCpyOptimizer.cpp Make getParamAlignment use argument numbers 2017-04-28 20:34:27 +00:00
MergedLoadStoreMotion.cpp Remove inclusion of SSAUpdater from several passes. 2017-01-29 01:55:24 +00:00
NaryReassociate.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
NewGVN.cpp [NewGVN] Fix typo and format comment. NFCI. 2017-05-02 21:11:40 +00:00
PartiallyInlineLibCalls.cpp Rename AttributeSet to AttributeList 2017-03-21 16:57:19 +00:00
PlaceSafepoints.cpp Apply clang-tidy's modernize-loop-convert to most of lib/Transforms. 2016-06-26 12:28:59 +00:00
Reassociate.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
Reg2Mem.cpp Apply clang-tidy's modernize-loop-convert to most of lib/Transforms. 2016-06-26 12:28:59 +00:00
RewriteStatepointsForGC.cpp Re-land r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList" 2017-05-02 22:07:37 +00:00
SCCP.cpp [IR] Redesign the case iterator in SwitchInst to actually be an iterator 2017-04-12 07:27:28 +00:00
SROA.cpp [SROA] Fix nondeterminism exposed by Simon's r299221. 2017-04-27 23:09:01 +00:00
Scalar.cpp [PM/LoopUnswitch] Introduce a new, simpler loop unswitch pass. 2017-04-27 18:45:20 +00:00
Scalarizer.cpp [Scalarizer] Handle scalar arguments in vector GEP 2017-03-31 06:29:49 +00:00
SeparateConstOffsetFromGEP.cpp Rename isKnownNotFullPoison to programUndefinedIfPoison; NFC 2017-04-30 19:41:19 +00:00
SimpleLoopUnswitch.cpp [PM/LoopUnswitch] Introduce a new, simpler loop unswitch pass. 2017-04-27 18:45:20 +00:00
SimplifyCFGPass.cpp Split the SimplifyCFG pass into two variants. 2017-03-26 06:44:08 +00:00
Sink.cpp Remove unnecessary IDom check 2017-03-20 00:30:19 +00:00
SpeculativeExecution.cpp SpeculativeExecution: Stop using whitelist for costs 2017-05-02 18:02:18 +00:00
StraightLineStrengthReduce.cpp IR: Change the gep_type_iterator API to avoid always exposing the "current" type. 2016-12-02 02:24:42 +00:00
StructurizeCFG.cpp Revert "StructurizeCFG: Directly invert cmp instructions" 2017-04-24 20:25:01 +00:00
TailRecursionElimination.cpp [TRE] Remove dead code 2016-11-07 22:17:37 +00:00