llvm-6502/include/llvm/Analysis
Arnold Schwaighofer 65457b679a Costmodel: Add support for horizontal vector reductions
Upcoming SLP vectorization improvements will want to be able to estimate costs
of horizontal reductions. Add infrastructure to support this.

We model reductions as a series of (shufflevector,add) tuples ultimately
followed by an extractelement. For example, for an add-reduction of <4 x float>
we could generate the following sequence:

 (v0, v1, v2, v3)
   \   \  /  /
     \  \  /
       +  +

 (v0+v2, v1+v3, undef, undef)
    \      /
 ((v0+v2) + (v1+v3), undef, undef)

 %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef,
                           <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
 %bin.rdx = fadd <4 x float> %rdx, %rdx.shuf
 %rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef,
                          <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
 %bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7
 %r = extractelement <4 x float> %bin.rdx8, i32 0

This commit adds a cost model interface "getReductionCost(Opcode, Ty, Pairwise)"
that will allow clients to ask for the cost of such a reduction (as backends
might generate more efficient code than the cost of the individual instructions
summed up). This interface is excercised by the CostModel analysis pass which
looks for reduction patterns like the one above - starting at extractelements -
and if it sees a matching sequence will call the cost model interface.

We will also support a second form of pairwise reduction that is well supported
on common architectures (haddps, vpadd, faddp).

 (v0, v1, v2, v3)
  \   /    \  /
 (v0+v1, v2+v3, undef, undef)
    \     /
 ((v0+v1)+(v2+v3), undef, undef, undef)

  %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef,
        <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef>
  %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef,
        <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
  %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1
  %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef,
        <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
  %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef,
        <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
  %bin.rdx.1 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1
  %r = extractelement <4 x float> %bin.rdx.1, i32 0

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190876 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17 18:06:50 +00:00
..
AliasAnalysis.h Make BasicAliasAnalysis recognize the fact a noalias argument cannot alias another argument, even if the other argument is not itself marked noalias. 2013-05-28 08:17:48 +00:00
AliasSetTracker.h Remove unneeded #includes. 2013-03-18 23:33:44 +00:00
BlockFrequencyImpl.h Add some constantness. 2013-08-20 23:04:15 +00:00
BlockFrequencyInfo.h Fixed 80+ violation and added C++ to header. 2013-07-12 23:09:43 +00:00
BranchProbabilityInfo.h Add a new function attribute 'cold' to functions. 2013-05-24 12:26:52 +00:00
CallGraph.h Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CallGraphSCCPass.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
CallPrinter.h Added -view-callgraph module pass. 2013-01-11 17:28:14 +00:00
CaptureTracking.h Remove unneeded #includes. Use forward declarations instead. 2013-03-10 00:34:01 +00:00
CFG.h Add some constantness. 2013-08-20 23:04:15 +00:00
CFGPrinter.h Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CodeMetrics.h Switch CodeMetrics itself over to use TTI to determine if an instruction 2013-01-21 13:04:33 +00:00
ConstantFolding.h Add missing -*- C++ -*- to headers 2013-05-17 21:43:39 +00:00
ConstantsScanner.h
DependenceAnalysis.h Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size. 2013-07-14 04:42:23 +00:00
DominanceFrontier.h
DominatorInternals.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
Dominators.h Add some constantness. 2013-03-05 22:01:15 +00:00
DomPrinter.h
DOTGraphTraitsPass.h Remove redundant 'llvm::' qualifications 2013-01-13 16:01:15 +00:00
FindUsedTypes.h
InlineCost.h Remove unneeded #include. 2013-06-06 23:34:11 +00:00
InstructionSimplify.h Fix missing -*- C++ -*-s 2013-08-06 00:16:21 +00:00
Interval.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
IntervalIterator.h Fix a few typos in comments. 2013-03-05 22:05:16 +00:00
IntervalPartition.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
IVUsers.h Remove duplicated forward declaration. 2013-03-06 00:04:32 +00:00
LazyValueInfo.h Move TargetData to DataLayout. 2012-10-08 16:38:25 +00:00
LibCallAliasAnalysis.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
LibCallSemantics.h Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 2012-09-27 10:14:43 +00:00
Lint.h
Loads.h Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
LoopInfo.h Add support for llvm.vectorizer metadata 2013-05-28 20:00:34 +00:00
LoopInfoImpl.h Remove #includes from the commonly used LoopInfo.h. 2013-02-09 01:04:28 +00:00
LoopIterator.h Remove unneeded #includes. 2013-02-09 13:29:10 +00:00
LoopPass.h LoopPass.h doesn't require Function.h. Remove unneeded #include. 2013-01-11 01:03:32 +00:00
MemoryBuiltins.h Fix typo (ponted -> pointed) 2013-07-22 23:52:23 +00:00
MemoryDependenceAnalysis.h Memory Dependence Analysis (not mem-dep test) take advantage of "invariant.load" metadata. 2013-03-06 17:48:48 +00:00
Passes.h Remove -print-dbginfo as it is unused & bitrotten. 2013-03-08 18:17:46 +00:00
PathNumbering.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
PathProfileInfo.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
PHITransAddr.h Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
PostDominators.h Add a const version of findNearestCommonDominator to PostDom for convenience. 2013-06-09 15:09:30 +00:00
ProfileDataLoader.h Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
ProfileDataTypes.h
ProfileInfo.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
ProfileInfoLoader.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
ProfileInfoTypes.h
PtrUseVisitor.h Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
RegionInfo.h RegionInfo: Add helpers to replace entry/exit recursively 2013-04-10 06:54:49 +00:00
RegionIterator.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
RegionPass.h Fix a typo (ouput => output) 2013-05-17 12:31:43 +00:00
RegionPrinter.h
ScalarEvolution.h Teach ScalarEvolution about pointer address spaces 2013-09-10 19:55:24 +00:00
ScalarEvolutionExpander.h SCEVExpander fix. RAUW needs to update the InsertedExpressions cache. 2013-01-14 21:00:37 +00:00
ScalarEvolutionExpressions.h Pacify -Wnon-virtual-dtor 2013-02-15 23:51:59 +00:00
ScalarEvolutionNormalization.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
SparsePropagation.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
TargetTransformInfo.h Costmodel: Add support for horizontal vector reductions 2013-09-17 18:06:50 +00:00
Trace.h Fix include guards so they exactly match file names. 2013-01-10 00:45:19 +00:00
ValueTracking.h Move isKnownNonNull out of AliasAnalysis.h and into ValueTracking.cpp since 2013-01-31 02:40:59 +00:00
Verifier.h