llvm-6502/test/Transforms
Chandler Carruth a403ceb205 [LPM] Fix PR18643, another scary place where loop transforms failed to
preserve loop simplify of enclosing loops.

The problem here starts with LoopRotation which ends up cloning code out
of the latch into the new preheader it is buidling. This can create
a new edge from the preheader into the exit block of the loop which
breaks LoopSimplify form. The code tries to fix this by splitting the
critical edge between the latch and the exit block to get a new exit
block that only the latch dominates. This sadly isn't sufficient.

The exit block may be an exit block for multiple nested loops. When we
clone an edge from the latch of the inner loop to the new preheader
being built in the outer loop, we create an exiting edge from the outer
loop to this exit block. Despite breaking the LoopSimplify form for the
inner loop, this is fine for the outer loop. However, when we split the
edge from the inner loop to the exit block, we create a new block which
is in neither the inner nor outer loop as the new exit block. This is
a predecessor to the old exit block, and so the split itself takes the
outer loop out of LoopSimplify form. We need to split every edge
entering the exit block from inside a loop nested more deeply than the
exit block in order to preserve all of the loop simplify constraints.

Once we try to do that, a problem with splitting critical edges
surfaces. Previously, we tried a very brute force to update LoopSimplify
form by re-computing it for all exit blocks. We don't need to do this,
and doing this much will sometimes but not always overlap with the
LoopRotate bug fix. Instead, the code needs to specifically handle the
cases which can start to violate LoopSimplify -- they aren't that
common. We need to see if the destination of the split edge was a loop
exit block in simplified form for the loop of the source of the edge.
For this to be true, all the predecessors need to be in the exact same
loop as the source of the edge being split. If the dest block was
originally in this form, we have to split all of the deges back into
this loop to recover it. The old mechanism of doing this was
conservatively correct because at least *one* of the exiting blocks it
rewrote was the DestBB and so the DestBB's predecessors were fixed. But
this is a much more targeted way of doing it. Making it targeted is
important, because ballooning the set of edges touched prevents
LoopRotate from being able to split edges *it* needs to split to
preserve loop simplify in a coherent way -- the critical edge splitting
would sometimes find the other edges in need of splitting but not
others.

Many, *many* thanks for help from Nick reducing these test cases
mightily. And helping lots with the analysis here as this one was quite
tricky to track down.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200393 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29 13:16:53 +00:00
..
ADCE
ArgumentPromotion Update optimization passes to handle inalloca arguments 2014-01-28 02:38:36 +00:00
BBVectorize
BranchFolding
CodeExtractor
CodeGenPrepare
ConstantHoisting/X86 ConstantHoisting: We can't insert instructions directly in front of a PHI node. 2014-01-27 13:11:43 +00:00
ConstantMerge Corruptly merge constants with explicit and implicit alignments. 2013-11-12 20:21:43 +00:00
ConstProp
CorrelatedValuePropagation
DeadArgElim Debug Info: update testing cases to specify the debug info version number. 2013-11-22 21:49:45 +00:00
DeadStoreElimination Update optimization passes to handle inalloca arguments 2014-01-28 02:38:36 +00:00
DebugIR
EarlyCSE
FunctionAttrs Update optimization passes to handle inalloca arguments 2014-01-28 02:38:36 +00:00
GCOVProfiling Debug Info: update testing cases to specify the debug info version number. 2013-11-22 21:49:45 +00:00
GlobalDCE
GlobalOpt Delete unread globals through addrspacecast 2014-01-02 20:01:43 +00:00
GVN Fix broken CHECK lines. 2014-01-11 21:06:00 +00:00
IndVarSimplify [LPM] Fix PR18642, a pretty nasty bug in IndVars that "never mattered" 2014-01-29 04:40:19 +00:00
Inline Fix known typos 2014-01-24 17:20:08 +00:00
InstCombine Update optimization passes to handle inalloca arguments 2014-01-28 02:38:36 +00:00
InstSimplify InstSimplify: Make shift, select and GEP simplifications vector-aware. 2014-01-24 17:09:53 +00:00
Internalize Correct word hyphenations 2013-12-05 05:44:44 +00:00
IPConstantProp
JumpThreading Don't eliminate a partially redundant load if it's in a landing pad. 2013-10-21 04:09:17 +00:00
LCSSA
LICM [LPM] Make LCSSA a utility with a FunctionPass that applies it to all 2014-01-25 04:07:24 +00:00
LoopDeletion
LoopIdiom Debug Info: update testing cases to specify the debug info version number. 2013-11-23 01:16:29 +00:00
LoopReroll Fix loop rerolling pass failure with non-consant loop lower bound 2014-01-03 17:20:01 +00:00
LoopRotate [LPM] Fix PR18643, another scary place where loop transforms failed to 2014-01-29 13:16:53 +00:00
LoopSimplify [LPM] Make LCSSA a utility with a FunctionPass that applies it to all 2014-01-25 04:07:24 +00:00
LoopStrengthReduce Fix broken CHECK lines. 2014-01-11 21:06:00 +00:00
LoopUnroll
LoopUnswitch
LoopVectorize [vectorizer] Completely disable the block frequency guidance of the loop 2014-01-28 09:10:41 +00:00
LowerAtomic
LowerExpectIntrinsic
LowerInvoke
LowerSwitch
Mem2Reg Debug Info: update testing cases to specify the debug info version number. 2013-11-22 21:49:45 +00:00
MemCpyOpt Handle an addrspacecast case in memcpyopt 2014-01-22 21:53:19 +00:00
MergeFunc PR17925 bugfix. 2013-11-26 16:11:03 +00:00
MetaRenamer
ObjCARC Fix known typos 2014-01-24 17:20:08 +00:00
PhaseOrdering
PruneEH
Reassociate
Reg2Mem
SampleProfile llvm/test/Transforms/SampleProfile/syntax.ll: Eliminate locale-sensitive message check. 2014-01-11 09:23:52 +00:00
Scalarizer Fix Scalarizer insertion point when replacing PHIs with insertelements 2013-12-23 14:51:56 +00:00
ScalarRepl Debug Info: update testing cases to specify the debug info version number. 2013-11-22 21:49:45 +00:00
SCCP
SimplifyCFG Fix pr14893. 2014-01-28 16:56:46 +00:00
Sink
SLPVectorizer Fix broken CHECK lines. 2014-01-11 21:06:00 +00:00
SROA Fix a really nasty SROA bug with how we handled out-of-bounds memcpy 2014-01-19 12:16:54 +00:00
StripSymbols Debug Info: update testing cases to specify the debug info version number. 2013-11-22 21:49:45 +00:00
StructurizeCFG StructurizeCFG: Fix verification failure with some loops. 2013-11-22 19:24:39 +00:00
TailCallElim
TailDup