diff options
author | Andrew Trick <atrick@apple.com> | 2013-02-09 01:11:01 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2013-02-09 01:11:01 +0000 |
commit | bc7059032b1d6c45d67db5e52eaae089638cffef (patch) | |
tree | 9612a390ce18af2929bb65660448b7a8eca97839 /llvm/lib/Transforms | |
parent | 58c61e006f4dce1abb90e4f7c6acd03c16fdd026 (diff) | |
download | bcm5719-llvm-bc7059032b1d6c45d67db5e52eaae089638cffef.tar.gz bcm5719-llvm-bc7059032b1d6c45d67db5e52eaae089638cffef.zip |
LSR IVChain improvement.
Handle chains in which the same offset is used for both loads and
stores to the same array.
Fixes rdar://11410078.
llvm-svn: 174789
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index b83bec2d8ae..5847dfeff31 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2537,6 +2537,7 @@ void LSRInstance::ChainInstruction(Instruction *UserInst, Instruction *IVOper, // Add this IV user to the end of the chain. IVChainVec[ChainIdx].add(IVInc(UserInst, IVOper, LastIncExpr)); } + IVChain &Chain = IVChainVec[ChainIdx]; SmallPtrSet<Instruction*,4> &NearUsers = ChainUsersVec[ChainIdx].NearUsers; // This chain's NearUsers become FarUsers. @@ -2554,8 +2555,19 @@ void LSRInstance::ChainInstruction(Instruction *UserInst, Instruction *IVOper, for (Value::use_iterator UseIter = IVOper->use_begin(), UseEnd = IVOper->use_end(); UseIter != UseEnd; ++UseIter) { Instruction *OtherUse = dyn_cast<Instruction>(*UseIter); - if (!OtherUse || OtherUse == UserInst) + if (!OtherUse) continue; + // Uses in the chain will no longer be uses if the chain is formed. + // Include the head of the chain in this iteration (not Chain.begin()). + IVChain::const_iterator IncIter = Chain.Incs.begin(); + IVChain::const_iterator IncEnd = Chain.Incs.end(); + for( ; IncIter != IncEnd; ++IncIter) { + if (IncIter->UserInst == OtherUse) + break; + } + if (IncIter != IncEnd) + continue; + if (SE.isSCEVable(OtherUse->getType()) && !isa<SCEVUnknown>(SE.getSCEV(OtherUse)) && IU.isIVUserOrOperand(OtherUse)) { |