1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 20:43:44 +02:00
llvm-mirror/lib/Analysis
Haicheng Wu 5b13afc1d2 Reapply "[LoopUnroll] Use the upper bound of the loop trip count to fullly unroll a loop"
Reappy r284044 after revert in r284051. Krzysztof fixed the error in r284049.

The original summary:

This patch tries to fully unroll loops having break statement like this

for (int i = 0; i < 8; i++) {
    if (a[i] == value) {
        found = true;
        break;
    }
}

GCC can fully unroll such loops, but currently LLVM cannot because LLVM only
supports loops having exact constant trip counts.

The upper bound of the trip count can be obtained from calling
ScalarEvolution::getMaxBackedgeTakenCount(). Part of the patch is the
refactoring work in SCEV to prevent duplicating code.

The feature of using the upper bound is enabled under the same circumstance
when runtime unrolling is enabled since both are used to unroll loops without
knowing the exact constant trip count.

llvm-svn: 284053
2016-10-12 21:29:38 +00:00
..
AliasAnalysis.cpp [AliasAnalysis] Give back AA results for fence instructions 2016-07-15 17:19:24 +00:00
AliasAnalysisEvaluator.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
AliasAnalysisSummary.cpp Update a comment. 2016-08-25 01:29:55 +00:00
AliasAnalysisSummary.h Make some LLVM_CONSTEXPR variables const. NFC. 2016-08-25 01:05:08 +00:00
AliasSetTracker.cpp [AliasSetTracker] Degrade AliasSetTracker when may-alias sets get too large. 2016-08-19 17:05:22 +00:00
Analysis.cpp [PM] Port CFGViewer and CFGPrinter to the new Pass Manager 2016-09-15 18:35:27 +00:00
AssumptionCache.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
BasicAliasAnalysis.cpp Replace a few more "fall through" comments with LLVM_FALLTHROUGH 2016-08-17 20:30:52 +00:00
BlockFrequencyInfo.cpp Turn cl::values() (for enum) from a vararg function to using C++ variadic template 2016-10-08 19:41:06 +00:00
BlockFrequencyInfoImpl.cpp [GraphTraits] Replace all NodeType usage with NodeRef 2016-08-22 21:09:30 +00:00
BranchProbabilityInfo.cpp Enhance calcColdCallHeuristics for InvokeInst 2016-09-23 17:26:14 +00:00
CallGraph.cpp Consistently use ModuleAnalysisManager 2016-08-09 00:28:38 +00:00
CallGraphSCCPass.cpp Use StringRef in Pass/PassManager APIs (NFC) 2016-10-01 02:56:57 +00:00
CallPrinter.cpp [CG] Rename the DOT printing pass to actually reference "DOT". 2016-03-10 11:04:40 +00:00
CaptureTracking.cpp [CaptureTracking] Volatile operations capture their memory location 2016-05-26 17:36:22 +00:00
CFG.cpp Avoid overly large SmallPtrSet/SmallSet 2016-01-30 01:24:31 +00:00
CFGPrinter.cpp [PM] Port CFGViewer and CFGPrinter to the new Pass Manager 2016-09-15 18:35:27 +00:00
CFLAndersAliasAnalysis.cpp Make some LLVM_CONSTEXPR variables const. NFC. 2016-08-25 01:05:08 +00:00
CFLGraph.h [CFLAA] Check for pointer types in more places. 2016-07-29 01:23:45 +00:00
CFLSteensAliasAnalysis.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
CGSCCPassManager.cpp Fixup r279618, instantiate *AnalysisManagerProxy<*AnalysisManager,LazyCallGraph::SCC>, instead of *AnalysisManagerProxy<*AnalysisManager,LazyCallGraph::SCC,LazyCallGraph&>, for PassID. 2016-08-30 15:47:13 +00:00
CMakeLists.txt [BPI] Add new LazyBPI analysis 2016-07-28 23:31:12 +00:00
CodeMetrics.cpp [Assumptions] Make collecting ephemeral values not quadratic in the 2016-08-18 17:51:24 +00:00
ConstantFolding.cpp [ConstantFold] Improve the bitcast folding logic for constant vectors. 2016-09-13 14:50:47 +00:00
CostModel.cpp [LV, X86] Be more optimistic about vectorizing shifts. 2016-08-04 22:48:03 +00:00
Delinearization.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
DemandedBits.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
DependenceAnalysis.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
DivergenceAnalysis.cpp DivergenceAnalysis: Fix crash with no return blocks 2016-05-09 16:57:08 +00:00
DominanceFrontier.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
DomPrinter.cpp Introduce analysis pass to compute PostDominators in the new pass manager. NFC 2016-02-25 17:54:07 +00:00
EHPersonalities.cpp Use the range variant of find instead of unpacking begin/end 2016-08-11 22:21:41 +00:00
GlobalsModRef.cpp Make GlobalsAA ignore dead constant expressions. 2016-10-04 00:03:55 +00:00
IndirectCallPromotionAnalysis.cpp Remove another unused variable from r275216 2016-07-12 23:49:17 +00:00
InlineCost.cpp Rename isHotFunction/isColdFunction to isFunctionEntryHot/isFunctionEntryCold. (NFC) 2016-10-10 21:47:28 +00:00
InstCount.cpp
InstructionSimplify.cpp Remove duplicated code; NFC 2016-10-02 00:09:57 +00:00
Interval.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
IntervalPartition.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
IteratedDominanceFrontier.cpp Normalize file docs. NFC. 2016-07-21 20:52:35 +00:00
IVUsers.cpp Consistently use LoopAnalysisManager 2016-08-09 00:28:52 +00:00
LazyBlockFrequencyInfo.cpp [BPI] Add new LazyBPI analysis 2016-07-28 23:31:12 +00:00
LazyBranchProbabilityInfo.cpp [BPI] Add new LazyBPI analysis 2016-07-28 23:31:12 +00:00
LazyCallGraph.cpp [LCG] Add the necessary functionality to the LazyCallGraph to support inlining. 2016-10-12 07:59:56 +00:00
LazyValueInfo.cpp Remove duplicated code; NFC 2016-10-02 00:09:57 +00:00
Lint.cpp Fix some Clang-tidy modernize-use-using and Include What You Use warnings. 2016-08-13 00:50:41 +00:00
LLVMBuild.txt Refactor indirect call promotion profitability analysis (NFC) 2016-07-12 21:13:44 +00:00
Loads.cpp [Loads] Properly populate the visited set in isDereferenceableAndAlignedPointer 2016-08-31 03:22:32 +00:00
LoopAccessAnalysis.cpp [LAA, LV] Port to new streaming interface for opt remarks. Update LV 2016-09-30 00:01:30 +00:00
LoopInfo.cpp [LCSSA] Implement linear algorithm for the isRecursivelyLCSSAForm 2016-10-11 13:37:22 +00:00
LoopPass.cpp Consistently use LoopAnalysisManager 2016-08-09 00:28:52 +00:00
LoopPassManager.cpp PM: Check that loop passes preserve a basic set of analyses 2016-05-03 21:35:08 +00:00
LoopUnrollAnalyzer.cpp [LoopUnrollAnalyzer] Handle out of bounds accesses in visitLoad 2016-07-23 02:56:49 +00:00
MemDepPrinter.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
MemDerefPrinter.cpp NFC. Move isDereferenceable to Loads.h/cpp 2016-02-24 12:49:04 +00:00
MemoryBuiltins.cpp Make some LLVM_CONSTEXPR variables const. NFC. 2016-08-25 01:05:08 +00:00
MemoryDependenceAnalysis.cpp Test commit access (NFC) 2016-10-06 10:58:41 +00:00
MemoryLocation.cpp [TLI] Unify LibFunc signature checking. NFCI. 2016-04-27 19:04:35 +00:00
ModuleDebugInfoPrinter.cpp Re-commit "Use StringRef in Support/Darf APIs (NFC)" 2016-10-05 05:59:29 +00:00
ModuleSummaryAnalysis.cpp [ThinLTO] Record calls to aliases 2016-10-08 16:11:42 +00:00
ObjCARCAliasAnalysis.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
ObjCARCAnalysisUtils.cpp [ARC] Pull the ObjC ARC components that really serve the role of 2015-08-20 08:06:03 +00:00
ObjCARCInstKind.cpp ObjCARC: Don't increment or dereference end() when scanning args 2016-08-17 01:02:18 +00:00
OptimizationDiagnosticInfo.cpp Don't filter diagnostics written as YAML to the output file 2016-10-04 18:13:45 +00:00
OrderedBasicBlock.cpp
PHITransAddr.cpp Use the range variant of find instead of unpacking begin/end 2016-08-11 22:21:41 +00:00
PostDominators.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
ProfileSummaryInfo.cpp Tune isHotFunction/isColdFunction 2016-10-11 05:19:00 +00:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp Turn cl::values() (for enum) from a vararg function to using C++ variadic template 2016-10-08 19:41:06 +00:00
RegionPass.cpp [RegionPass] Some minor cleanups 2016-07-19 17:50:27 +00:00
RegionPrinter.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
ScalarEvolution.cpp Reapply "[LoopUnroll] Use the upper bound of the loop trip count to fullly unroll a loop" 2016-10-12 21:29:38 +00:00
ScalarEvolutionAliasAnalysis.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
ScalarEvolutionExpander.cpp Create a getelementptr instead of sub expr for ValueOffsetPair if the 2016-09-14 04:39:50 +00:00
ScalarEvolutionNormalization.cpp Remove emacs mode markers from .cpp files. NFC 2016-04-24 17:55:41 +00:00
ScopedNoAliasAA.cpp [ScopedNoAliasAA] collectMDInDomain should be a free function 2016-08-15 03:56:06 +00:00
SparsePropagation.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
StratifiedSets.h [CFLAA] Simplify CFLGraphBuilder. NFC. 2016-07-11 22:59:09 +00:00
TargetLibraryInfo.cpp Turn cl::values() (for enum) from a vararg function to using C++ variadic template 2016-10-08 19:41:06 +00:00
TargetTransformInfo.cpp [ARM] Don't convert switches to lookup tables of pointers with ROPI/RWPI 2016-10-07 08:48:24 +00:00
Trace.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
TypeBasedAliasAnalysis.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
TypeMetadataUtils.cpp [IR] Make getIndexedOffsetInType return a signed result 2016-07-13 03:42:38 +00:00
ValueTracking.cpp [ValueTracking] An improvement to IR ValueTracking on Non-negative Integers 2016-10-12 16:18:43 +00:00
VectorUtils.cpp Add handling of !invariant.load to PropagateMetadata. 2016-09-11 01:39:08 +00:00

Analysis Opportunities:

//===---------------------------------------------------------------------===//

In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
ScalarEvolution expression for %r is this:

  {1,+,3,+,2}<loop>

Outside the loop, this could be evaluated simply as (%n * %n), however
ScalarEvolution currently evaluates it as

  (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))

In addition to being much more complicated, it involves i65 arithmetic,
which is very inefficient when expanded into code.

//===---------------------------------------------------------------------===//

In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,

ScalarEvolution is forming this expression:

((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))

This could be folded to

(-1 * (trunc i64 undef to i32))

//===---------------------------------------------------------------------===//