llvm-6502/lib/Transforms/Scalar
Chandler Carruth ce7f347da2 [SROA] Teach SROA to be more aggressive in splitting now that we have
a pre-splitting pass over loads and stores.

Historically, splitting could cause enough problems that I hamstrung the
entire process with a requirement that splittable integer loads and
stores must cover the entire alloca. All smaller loads and stores were
unsplittable to prevent chaos from ensuing. With the new pre-splitting
logic that does load/store pair splitting I introduced in r225061, we
can now very nicely handle arbitrarily splittable loads and stores. In
order to fully benefit from these smarts, we need to mark all of the
integer loads and stores as splittable.

However, we don't actually want to rewrite partitions with all integer
loads and stores marked as splittable. This will fail to extract scalar
integers from aggregates, which is kind of the point of SROA. =] In
order to resolve this, what we really want to do is only do
pre-splitting on the alloca slices with integer loads and stores fully
splittable. This allows us to uncover all non-integer uses of the alloca
that would benefit from a split in an integer load or store (and where
introducing the split is safe because it is just memory transfer from
a load to a store). Once done, we make all the non-whole-alloca integer
loads and stores unsplittable just as they have historically been,
repartition and rewrite.

The result is that when there are integer loads and stores anywhere
within an alloca (such as from a memcpy of a sub-object of a larger
object), we can split them up if there are non-integer components to the
aggregate hiding beneath. I've added the challenging test cases to
demonstrate how this is able to promote to scalars even a case where we
have even *partially* overlapping loads and stores.

This restores the single-store behavior for small arrays of i8s which is
really nice. I've restored both the little endian testing and big endian
testing for these exactly as they were prior to r225061. It also forced
me to be more aggressive in an alignment test to actually defeat SROA.
=] Without the added volatiles there, we actually split up the weird i16
loads and produce nice double allocas with better alignment.

This also uncovered a number of bugs where we failed to handle
splittable load and store slices which didn't have a begininng offset of
zero. Those fixes are included, and without them the existing test cases
explode in glorious fireworks. =]

I've kept support for leaving whole-alloca integer loads and stores as
splittable even for the purpose of rewriting, but I think that's likely
no longer needed. With the new pre-splitting, we might be able to remove
all the splitting support for loads and stores from the rewriter. Not
doing that in this patch to try to isolate any performance regressions
that causes in an easy to find and revert chunk.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225074 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02 03:55:54 +00:00
..
ADCE.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
AlignmentFromAssumptions.cpp [AlignmentFromAssumptions] Don't crash just because the target is 32-bit 2014-09-11 08:40:17 +00:00
CMakeLists.txt Add an AlignmentFromAssumptions Pass 2014-09-07 20:05:11 +00:00
ConstantHoisting.cpp Remove unnecessary copying or replace it with moves in a bunch of places. 2014-10-04 16:55:56 +00:00
ConstantProp.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
CorrelatedValuePropagation.cpp Make use of @llvm.assume from LazyValueInfo 2014-09-07 20:29:59 +00:00
DCE.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:55:47 +00:00
DeadStoreElimination.cpp [DSE] Remove no-data-layout-only type-based overlap checking 2014-10-17 11:56:00 +00:00
EarlyCSE.cpp Tweak EarlyCSE to recognize series of dead stores 2014-11-18 17:46:32 +00:00
FlattenCFGPass.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:55:47 +00:00
GVN.cpp Revert r222039 because of bot failure. 2014-11-19 00:13:26 +00:00
IndVarSimplify.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
JumpThreading.cpp Revert r220349 to re-instate r220277 with a fix for PR21330 -- quite 2014-11-25 08:20:27 +00:00
LICM.cpp Refine the notion of MayThrow in LICM to include a header specific version 2014-12-29 23:00:57 +00:00
LLVMBuild.txt ScalarOpts/LLVMBuild.txt: Prune unused dependency to IPA. 2014-09-09 15:00:38 +00:00
LoadCombine.cpp Use AA in LoadCombine 2014-11-03 23:19:16 +00:00
LoopDeletion.cpp Use range based for loops to avoid needing to re-mention SmallPtrSet size. 2014-08-24 23:23:06 +00:00
LoopIdiomRecognize.cpp Remove extra whitespace in function declaration. No functionality change. 2014-06-14 03:48:29 +00:00
LoopInstSimplify.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
LoopRerollPass.cpp Reformat partially, where I touched for whitespace changes. 2014-10-28 11:54:52 +00:00
LoopRotation.cpp Do not simplifyLatch for loops where hoisting increments couldresult in extra live range interferance 2014-10-29 20:19:47 +00:00
LoopStrengthReduce.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
LoopUnrollPass.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
LoopUnswitch.cpp Add functions for finding ephemeral values 2014-09-07 13:49:57 +00:00
LowerAtomic.cpp IR: add "cmpxchg weak" variant to support permitted failure. 2014-06-13 14:24:07 +00:00
Makefile
MemCpyOptimizer.cpp Allow call-slop optzn for destinations with a suitable dereferenceable attribute 2014-10-16 19:43:08 +00:00
MergedLoadStoreMotion.cpp Sink store based on alias analysis 2014-12-15 14:09:53 +00:00
PartiallyInlineLibCalls.cpp PartiallyInlineLibCalls: Check sqrt result type before transforming it. 2014-08-01 23:21:21 +00:00
Reassociate.cpp [Reassociate] Use dbgs() instead of errs(). 2014-12-12 14:44:12 +00:00
Reg2Mem.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:55:47 +00:00
SampleProfile.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
Scalar.cpp [C API] Make the 'lower switch' pass available via the C API. 2014-09-11 21:32:32 +00:00
Scalarizer.cpp Revert "IR: MDNode => Value" 2014-11-11 21:30:22 +00:00
ScalarReplAggregates.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
SCCP.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
SeparateConstOffsetFromGEP.cpp [SeparateConstOffsetFromGEP] Allow SeparateConstOffsetFromGEP pass to lower GEPs. 2014-11-19 06:24:44 +00:00
SimplifyCFGPass.cpp [SimplifyCFG] threshold for folding branches with common destination 2014-09-30 22:23:38 +00:00
Sink.cpp Use range based for loops to avoid needing to re-mention SmallPtrSet size. 2014-08-24 23:23:06 +00:00
SROA.cpp [SROA] Teach SROA to be more aggressive in splitting now that we have 2015-01-02 03:55:54 +00:00
StructurizeCFG.cpp StructurizeCFG: Use LoopInfo analysis for better loop detection 2014-12-03 04:28:32 +00:00
TailRecursionElimination.cpp Fix tail recursion elimination 2014-11-19 13:32:51 +00:00