llvm-6502/lib/Transforms/Scalar
Andrew Trick fcf79528da Rotate multi-exit loops even if the latch was simplified.
Test case by Michele Scandale!

Fixes PR10293: Load not hoisted out of loop with multiple exits.

There are few regressions with this patch, now tracked by
rdar:13817079, and a roughly equal number of improvements. The
regressions are almost certainly back luck because LoopRotate has very
little idea of whether rotation is profitable. Doing better requires a
more comprehensive solution.

This checkin is a quick fix that lacks generality (PR10293 has
a counter-example). But it trivially fixes the case in PR10293 without
interfering with other cases, and it does satify the criteria that
LoopRotate is a loop canonicalization pass that should avoid
heuristics and special cases.

I can think of two approaches that would probably be better in
the long run. Ultimately they may both make sense.

(1) LoopRotate should check that the current header would make a good
loop guard, and that the loop does not already has a sufficient
guard. The artifical SimplifiedLoopLatch check would be unnecessary,
and the design would be more general and canonical. Two difficulties:

- We need a strong guarantee that we won't endlessly rotate, so the
  analysis would need to be precise in order to avoid the
  SimplifiedLoopLatch precondition.

- Analysis like this are usually based on SCEV, which we don't want to
  rely on.

(2) Rotate on-demand in late loop passes. This could even be done by
shoving the loop back on the queue after the optimization that needs
it. This could work well when we find LICM opportunities in
multi-branch loops. This requires some work, and it doesn't really
solve the problem of SCEV wanting a loop guard before the analysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181230 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-06 17:58:18 +00:00
..
ADCE.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
BasicBlockPlacement.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CMakeLists.txt Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00
CodeGenPrepare.cpp Fix a typo in comment. 2013-04-15 17:40:48 +00:00
ConstantProp.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CorrelatedValuePropagation.cpp CVP: If we have a PHI with an incoming select, try to skip the select. 2013-02-24 15:34:43 +00:00
DCE.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
DeadStoreElimination.cpp Change GetPointerBaseWithConstantOffset's DataLayout argument from a 2013-01-31 02:00:45 +00:00
EarlyCSE.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
GlobalMerge.cpp Clarify that llvm.used can contain aliases. 2013-04-22 14:58:02 +00:00
GVN.cpp Decompose GVN::processNonLocalLoad() (about 400 LOC) into smaller helper functions. No function change. 2013-05-03 19:17:26 +00:00
IndVarSimplify.cpp IndVarSimplify: do not recompute an IV value outside of the loop if : 2013-03-19 20:00:22 +00:00
JumpThreading.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
LICM.cpp LICM: Hoist insertvalue/extractvalue out of loops. 2013-01-09 18:12:03 +00:00
LLVMBuild.txt
LoopDeletion.cpp Make method private. Keep coding standard. 2013-03-18 23:31:30 +00:00
LoopIdiomRecognize.cpp PR14904: Segmentation fault running pass 'Recognize loop idioms' 2013-01-10 23:32:01 +00:00
LoopInstSimplify.cpp Remove #includes from the commonly used LoopInfo.h. 2013-02-09 01:04:28 +00:00
LoopRotation.cpp Rotate multi-exit loops even if the latch was simplified. 2013-05-06 17:58:18 +00:00
LoopStrengthReduce.cpp Use dyn_cast instead of isa && cast. 2013-03-24 09:25:47 +00:00
LoopUnrollPass.cpp Switch CodeMetrics itself over to use TTI to determine if an instruction 2013-01-21 13:04:33 +00:00
LoopUnswitch.cpp Switch CodeMetrics itself over to use TTI to determine if an instruction 2013-01-21 13:04:33 +00:00
LowerAtomic.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
Makefile
MemCpyOptimizer.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
Reassociate.cpp Fix a XOR reassociation bug. 2013-04-27 18:02:12 +00:00
Reg2Mem.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
Scalar.cpp This patch breaks up Wrap.h so that it does not have to include all of 2013-05-01 20:59:00 +00:00
ScalarReplAggregates.cpp Fix a comment, PR15777. 2013-04-18 17:42:14 +00:00
SCCP.cpp Remove dead code and whitespace. 2013-02-21 21:40:51 +00:00
SimplifyCFGPass.cpp Make SimplifyCFG simply depend upon TargetTransformInfo and pass it 2013-01-07 03:53:25 +00:00
SimplifyLibCalls.cpp simplify-libcalls: Removed unused variable 2013-03-21 02:44:07 +00:00
Sink.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
SROA.cpp SROA: Generate selects instead of shuffles when blending values because this is the cannonical form. 2013-05-01 19:53:30 +00:00
TailRecursionElimination.cpp Begin fleshing out an interface in TTI for modelling the costs of 2013-01-22 11:26:02 +00:00