[llvm] r184671 - SLP Vectorizer: Erase instructions outside the vectorizeTree method.
Nadav Rotem
nrotem at apple.com
Sun Jun 23 12:38:57 PDT 2013
Author: nadav
Date: Sun Jun 23 14:38:56 2013
New Revision: 184671
URL: http://llvm.org/viewvc/llvm-project?rev=184671&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=184671&r1=184670&r2=184671&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Sun Jun 23 14:38:56 2013
@@ -848,6 +848,12 @@ bool FuncSLP::vectorizeStoreChain(ArrayR
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(ArrayR
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(ArrayR
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:
More information about the llvm-commits
mailing list