llvm-6502/lib/CodeGen/SelectionDAG
Hans Wennborg cc987d98bb Switch lowering: extract jump tables and bit tests before building binary tree (PR22262)
This is a major rewrite of the SelectionDAG switch lowering. The previous code
would lower switches as a binary tre, discovering clusters of cases
suitable for lowering by jump tables or bit tests as it went along. To increase
the likelihood of finding jump tables, the binary tree pivot was selected to
maximize case density on both sides of the pivot.

By not selecting the pivot in the middle, the binary trees would not always
be balanced, leading to performance problems in the generated code.

This patch rewrites the lowering to search for clusters of cases
suitable for jump tables or bit tests first, and then builds the binary
tree around those clusters. This way, the binary tree will always be balanced.

This has the added benefit of decoupling the different aspects of the lowering:
tree building and jump table or bit tests finding are now easier to tweak
separately.

For example, this will enable us to balance the tree based on profile info
in the future.

The algorithm for finding jump tables is O(n^2), whereas the previous algorithm
was O(n log n) for common cases, and quadratic only in the worst-case. This
doesn't seem to be major problem in practice, e.g. compiling a file consisting
of a 10k-case switch was only 30% slower, and such large switches should be rare
in practice. Compiling e.g. gcc.c showed no compile-time difference.  If this
does turn out to be a problem, we could limit the search space of the algorithm.

This commit also disables all optimizations during switch lowering in -O0.

Differential Revision: http://reviews.llvm.org/D8649

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235101 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-16 14:49:23 +00:00
..
CMakeLists.txt
DAGCombiner.cpp [CodeGen] Re-apply r234809 (concat of scalars), with an x86_mmx fix. 2015-04-16 02:39:14 +00:00
FastISel.cpp CodeGen: Stop using DIDescriptor::is*() and auto-casting 2015-04-06 23:27:40 +00:00
FunctionLoweringInfo.cpp Add range iterators for post order and inverse post order. Use them 2015-04-15 17:41:42 +00:00
InstrEmitter.cpp CodeGen: Stop using DIDescriptor::is*() and auto-casting 2015-04-06 23:27:40 +00:00
InstrEmitter.h
LegalizeDAG.cpp [AArch64] Promote f16 operations to f32. 2015-04-10 00:08:48 +00:00
LegalizeFloatTypes.cpp Fix makeLibCall argument (signed) in SoftenFloatRes_XINT_TO_FP function 2015-02-10 23:30:14 +00:00
LegalizeIntegerTypes.cpp Revert revisions r234755, r234759, r234760 2015-04-13 17:47:15 +00:00
LegalizeTypes.cpp
LegalizeTypes.h [SDAG] Move TRUNCATE splitting logic into a helper, and use 2015-03-31 10:20:58 +00:00
LegalizeTypesGeneric.cpp
LegalizeVectorOps.cpp fix typo and 80-col; NFC 2015-03-27 21:45:18 +00:00
LegalizeVectorTypes.cpp [SDAG] Move TRUNCATE splitting logic into a helper, and use 2015-03-31 10:20:58 +00:00
LLVMBuild.txt
Makefile
ResourcePriorityQueue.cpp unique_ptrify ResourcePriorityQueue::ResourceModel 2015-03-03 20:49:08 +00:00
ScheduleDAGFast.cpp
ScheduleDAGRRList.cpp Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
ScheduleDAGSDNodes.cpp Prefer SmallVector::append/insert over push_back loops. 2015-02-17 15:29:18 +00:00
ScheduleDAGSDNodes.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
ScheduleDAGVLIW.cpp Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
SDNodeDbgValue.h
SelectionDAG.cpp TRUNCATE constant folding - minor fix for rL233224 2015-04-16 08:21:09 +00:00
SelectionDAGBuilder.cpp Switch lowering: extract jump tables and bit tests before building binary tree (PR22262) 2015-04-16 14:49:23 +00:00
SelectionDAGBuilder.h Switch lowering: extract jump tables and bit tests before building binary tree (PR22262) 2015-04-16 14:49:23 +00:00
SelectionDAGDumper.cpp DebugInfo: Gut DIScope, DIEnumerator and DISubrange 2015-04-16 01:37:00 +00:00
SelectionDAGISel.cpp Switch lowering: extract jump tables and bit tests before building binary tree (PR22262) 2015-04-16 14:49:23 +00:00
SelectionDAGPrinter.cpp
StatepointLowering.cpp Reduce dyn_cast<> to isa<> or cast<> where possible. 2015-04-10 11:24:51 +00:00
StatepointLowering.h
TargetLowering.cpp [CodeGen] Report error rather than crash when unable to makeLibCall. 2015-03-26 22:46:58 +00:00
TargetSelectionDAGInfo.cpp