diff options
| author | Nadav Rotem <nrotem@apple.com> | 2013-06-23 19:38:56 +0000 |
|---|---|---|
| committer | Nadav Rotem <nrotem@apple.com> | 2013-06-23 19:38:56 +0000 |
| commit | 78428401e9839c7c03859899b09f9b3ba417a4b0 (patch) | |
| tree | 4fbb2d352f3ee11b01f40aefa8eafd45edf3001d /llvm/lib | |
| parent | 5acff7e6912810c1e76620b5816bbe2ae3401538 (diff) | |
| download | bcm5719-llvm-78428401e9839c7c03859899b09f9b3ba417a4b0.tar.gz bcm5719-llvm-78428401e9839c7c03859899b09f9b3ba417a4b0.zip | |
SLP Vectorizer: Erase instructions outside the vectorizeTree method.
The RAII builder location guard is saving a reference to instructions, so we can't erase instructions during vectorization.
llvm-svn: 184671
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 4f378e3d600..838cb9599cb 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -848,6 +848,12 @@ bool FuncSLP::vectorizeStoreChain(ArrayRef<Value *> Chain, int CostThreshold) { if (Cost < CostThreshold) { DEBUG(dbgs() << "SLP: Decided to vectorize cost=" << Cost << "\n"); vectorizeTree(Operands); + + // Remove the scalar stores. + for (int i = 0, e = VF; i < e; ++i) + cast<Instruction>(Operands[i])->eraseFromParent(); + + // Move to the next bundle. i += VF - 1; Changed = true; } @@ -865,6 +871,11 @@ bool FuncSLP::vectorizeStoreChain(ArrayRef<Value *> Chain, int CostThreshold) { DEBUG(dbgs() << "SLP: Found store chain cost = " << Cost << " for size = " << ChainLen << "\n"); vectorizeTree(Chain); + + // Remove all of the scalar stores. + for (int i = 0, e = Chain.size(); i < e; ++i) + cast<Instruction>(Chain[i])->eraseFromParent(); + return true; } @@ -1100,9 +1111,6 @@ Value *FuncSLP::vectorizeTree_rec(ArrayRef<Value *> VL) { Value *VecPtr = Builder.CreateBitCast(SI->getPointerOperand(), VecTy->getPointerTo()); Builder.CreateStore(VecValue, VecPtr)->setAlignment(Alignment); - - for (int i = 0, e = VL.size(); i < e; ++i) - cast<Instruction>(VL[i])->eraseFromParent(); return 0; } default: |

