llvm-6502/test/Transforms
Chandler Carruth e78a87b633 Teach instcombine to canonicalize "element extraction" from a load of an
integer and "element insertion" into a store of an integer into actual
element extraction, element insertion, and vector loads and stores.

Previously various parts of LLVM (including instcombine itself) would
introduce integer loads and stores into the code as a way of opaquely
loading and storing "bits". In some cases (such as a memcpy of
std::complex<float> object) we will eventually end up using those bits
in non-integer types. In order for SROA to effectively promote the
allocas involved, it splits these "store a bag of bits" integer loads
and stores up into the constituent parts. However, for non-alloca loads
and tsores which remain, it uses integer math to recombine the values
into a large integer to load or store.

All of this would be "fine", except that it forces LLVM to go through
integer math to combine and split up values. While this makes perfect
sense for integers (and in fact is critical for bitfields to end up
lowering efficiently) it is *terrible* for non-integer types, especially
floating point types. We have a much more canonical way of representing
the act of concatenating the bits of two SSA values in LLVM: a vector
and insertelement. This patch teaching InstCombine to use this
representation.

With this patch applied, LLVM will no longer introduce integer math into
the critical path of every loop over std::complex<float> operations such
as those that make up the hot path of ... oh, most HPC code, Eigen, and
any other heavy linear algebra library.

For the record, I looked *extensively* at fixing this in other parts of
the compiler, but it just doesn't work:
- We really do want to canonicalize memcpy and other bit-motion to
  integer loads and stores. SSA values are tremendously more powerful
  than "copy" intrinsics. Not doing this regresses massive amounts of
  LLVM's scalar optimizer.
- We really do need to split up integer loads and stores of this form in
  SROA or every memcpy of a trivially copyable struct will prevent SSA
  formation of the members of that struct. It essentially turns off
  SROA.
- The closest alternative is to actually split the loads and stores when
  partitioning with SROA, but this has all of the downsides historically
  discussed of splitting up loads and stores -- the wide-store
  information is fundamentally lost. We would also see performance
  regressions for bitfield-heavy code and other places where the
  integers aren't really intended to be split without seemingly
  arbitrary logic to treat integers totally differently.
- We *can* effectively fix this in instcombine, so it isn't that hard of
  a choice to make IMO.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223764 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 08:55:32 +00:00
..
ADCE
AddDiscriminators
AlignmentFromAssumptions
ArgumentPromotion
AtomicExpand/ARM
BBVectorize
BranchFolding Delete -std-compile-opts. 2014-10-16 20:00:02 +00:00
CodeExtractor
CodeGenPrepare [CodeGenPrepare][AArch64] Fix a TLI legality check on iPTR to use a lowered instead. 2014-11-12 22:16:55 +00:00
ConstantHoisting
ConstantMerge
ConstProp
CorrelatedValuePropagation LazyValueInfo: Actually re-visit partially solved block-values in solveBlockValue() 2014-11-25 17:23:05 +00:00
DeadArgElim
DeadStoreElimination Parse 'ghccc' in .ll files as the GHC convention (cc 10) 2014-12-01 21:04:44 +00:00
EarlyCSE Tweak EarlyCSE to recognize series of dead stores 2014-11-18 17:46:32 +00:00
FunctionAttrs Normally an 'optnone' function goes through fast-isel, which does not 2014-11-03 18:19:26 +00:00
GCOVProfiling Fix test to use the right metadata node (reapply r223239 plus a fix) and also to use the correct path to the GCNO file. 2014-12-03 17:32:44 +00:00
GlobalDCE
GlobalOpt IR: Disallow complicated function-local metadata 2014-12-06 01:26:49 +00:00
GVN Relax an assert a bit to avoid a crash on unreachable code. 2014-12-01 02:55:24 +00:00
IndVarSimplify IndVarSimplify: Allow LFTR to fire more often 2014-11-18 02:20:58 +00:00
Inline Revert "Transforms: reapply SVN r219899" 2014-11-04 02:02:14 +00:00
InstCombine Teach instcombine to canonicalize "element extraction" from a load of an 2014-12-09 08:55:32 +00:00
InstMerge Use Alias Analysis to hoist 2 loads from diamond to the common predecessor basic block. 2014-11-02 08:03:05 +00:00
InstSimplify InstSimplify: Try to bring back the rest of r223583 2014-12-08 18:30:43 +00:00
Internalize
IPConstantProp
JumpThreading LazyValueInfo: Actually re-visit partially solved block-values in solveBlockValue() 2014-11-25 17:23:05 +00:00
LCSSA
LICM [LICM] Avoind store sinking if no preheader is available 2014-12-02 14:22:34 +00:00
LoadCombine Use AA in LoadCombine 2014-11-03 23:19:16 +00:00
LoopDeletion
LoopIdiom
LoopReroll
LoopRotate llvm/test/Transforms/LoopRotate/nosimplifylatch.ll: Fix possibly mis-repeatedly-pasted test. 2014-10-29 23:05:12 +00:00
LoopSimplify
LoopStrengthReduce
LoopUnroll Fix a trip-count overflow issue in LoopUnroll. 2014-11-20 20:19:55 +00:00
LoopUnswitch
LoopVectorize PR21302. Vectorize only bottom-tested loops. 2014-12-02 22:59:06 +00:00
LowerAtomic
LowerExpectIntrinsic
LowerInvoke
LowerSwitch
Mem2Reg Delete -std-compile-opts. 2014-10-16 20:00:02 +00:00
MemCpyOpt Allow call-slop optzn for destinations with a suitable dereferenceable attribute 2014-10-16 19:43:08 +00:00
MergeFunc
MetaRenamer
ObjCARC Add back r222061 with a fix. 2014-11-17 02:28:27 +00:00
PartiallyInlineLibCalls
PhaseOrdering
PruneEH
Reassociate Revert "[Reassociate] As the expression tree is rewritten make sure the operands are" 2014-11-19 23:21:20 +00:00
Reg2Mem
SampleProfile llvm/test/Transforms/SampleProfile/syntax.ll: Relax MISSING-FILE not to 2014-10-30 22:28:46 +00:00
Scalarizer
ScalarRepl
SCCP SCCP: overdefined calls cannot become constant 2014-11-07 08:54:19 +00:00
SeparateConstOffsetFromGEP/NVPTX [SeparateConstOffsetFromGEP] Fixed a bug related to unsigned modulo 2014-10-25 18:34:03 +00:00
SimplifyCFG Add some tests for SimplifyCFG's TurnSwitchRangeIntoICmp(). NFC. 2014-12-04 22:19:28 +00:00
Sink
SLPVectorizer Vectorize a reduction chain feeding into a 'return' statement. 2014-11-19 16:07:38 +00:00
SROA SROA: The alloca type isn't a candidate promotion type for vectors 2014-11-21 02:34:55 +00:00
StripSymbols
StructurizeCFG StructurizeCFG: Use LoopInfo analysis for better loop detection 2014-12-03 04:28:32 +00:00
TailCallElim Fix tail recursion elimination 2014-11-19 13:32:51 +00:00
TailDup
Util [SwitchLowering] Handle destinations on multiple phi instructions 2014-12-02 18:31:53 +00:00