summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-08-26 23:08:37 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-08-26 23:08:37 +0000
commited9f76d37bf643ea7c3e6dbe56c5a54a06c0b32c (patch)
tree15d4c094d3429673c66c5359b53bb05e6d6507e8
parent988661d30857d683d5eeb5b10e8656acad350371 (diff)
downloadbcm5719-llvm-ed9f76d37bf643ea7c3e6dbe56c5a54a06c0b32c.tar.gz
bcm5719-llvm-ed9f76d37bf643ea7c3e6dbe56c5a54a06c0b32c.zip
Fix inserting instructions before last in bundle.
The builder inserts from before the insert point, not after, so this would insert before the last instruction in the bundle instead of after it. I'm not sure if this can actually be a problem with any of the current insertions. llvm-svn: 189285
-rw-r--r--llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp36
-rw-r--r--llvm/test/Transforms/SLPVectorizer/X86/debug_info.ll2
2 files changed, 21 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 23a876d2a1e..57cd2a7f822 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -311,6 +311,10 @@ private:
/// \returns the Instruction in the bundle \p VL.
Instruction *getLastInstruction(ArrayRef<Value *> VL);
+ /// \brief Set the Builder insert point to one after the last instruction in
+ /// the bundle
+ void setInsertPointAfterBundle(ArrayRef<Value *> VL);
+
/// \returns a vector from a collection of scalars in \p VL.
Value *Gather(ArrayRef<Value *> VL, VectorType *Ty);
@@ -1068,6 +1072,15 @@ Instruction *BoUpSLP::getLastInstruction(ArrayRef<Value *> VL) {
return I;
}
+void BoUpSLP::setInsertPointAfterBundle(ArrayRef<Value *> VL) {
+ Instruction *VL0 = cast<Instruction>(VL[0]);
+ Instruction *LastInst = getLastInstruction(VL);
+ BasicBlock::iterator NextInst = LastInst;
+ ++NextInst;
+ Builder.SetInsertPoint(VL0->getParent(), NextInst);
+ Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+}
+
Value *BoUpSLP::Gather(ArrayRef<Value *> VL, VectorType *Ty) {
Value *Vec = UndefValue::get(Ty);
// Generate the 'InsertElement' instruction.
@@ -1141,10 +1154,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
VectorType *VecTy = VectorType::get(ScalarTy, E->Scalars.size());
if (E->NeedToGather) {
- BasicBlock::iterator NextInst = getLastInstruction(E->Scalars);
- ++NextInst;
- assert(NextInst != VL0->getParent()->end());
- Builder.SetInsertPoint(NextInst);
+ setInsertPointAfterBundle(E->Scalars);
return Gather(E->Scalars, VecTy);
}
@@ -1212,8 +1222,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
for (int i = 0, e = E->Scalars.size(); i < e; ++i)
INVL.push_back(cast<Instruction>(E->Scalars[i])->getOperand(0));
- Builder.SetInsertPoint(getLastInstruction(E->Scalars));
- Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+ setInsertPointAfterBundle(E->Scalars);
Value *InVec = vectorizeTree(INVL);
@@ -1233,8 +1242,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
RHSV.push_back(cast<Instruction>(E->Scalars[i])->getOperand(1));
}
- Builder.SetInsertPoint(getLastInstruction(E->Scalars));
- Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+ setInsertPointAfterBundle(E->Scalars);
Value *L = vectorizeTree(LHSV);
Value *R = vectorizeTree(RHSV);
@@ -1260,8 +1268,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
FalseVec.push_back(cast<Instruction>(E->Scalars[i])->getOperand(2));
}
- Builder.SetInsertPoint(getLastInstruction(E->Scalars));
- Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+ setInsertPointAfterBundle(E->Scalars);
Value *Cond = vectorizeTree(CondVec);
Value *True = vectorizeTree(TrueVec);
@@ -1298,8 +1305,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
RHSVL.push_back(cast<Instruction>(E->Scalars[i])->getOperand(1));
}
- Builder.SetInsertPoint(getLastInstruction(E->Scalars));
- Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+ setInsertPointAfterBundle(E->Scalars);
Value *LHS = vectorizeTree(LHSVL);
Value *RHS = vectorizeTree(RHSVL);
@@ -1319,8 +1325,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
case Instruction::Load: {
// Loads are inserted at the head of the tree because we don't want to
// sink them all the way down past store instructions.
- Builder.SetInsertPoint(getLastInstruction(E->Scalars));
- Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+ setInsertPointAfterBundle(E->Scalars);
LoadInst *LI = cast<LoadInst>(VL0);
Value *VecPtr =
@@ -1339,8 +1344,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
for (int i = 0, e = E->Scalars.size(); i < e; ++i)
ValueOp.push_back(cast<StoreInst>(E->Scalars[i])->getValueOperand());
- Builder.SetInsertPoint(getLastInstruction(E->Scalars));
- Builder.SetCurrentDebugLocation(VL0->getDebugLoc());
+ setInsertPointAfterBundle(E->Scalars);
Value *VecValue = vectorizeTree(ValueOp);
Value *VecPtr =
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/debug_info.ll b/llvm/test/Transforms/SLPVectorizer/X86/debug_info.ll
index 1c867dba854..23bad98de71 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/debug_info.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/debug_info.ll
@@ -19,7 +19,7 @@ target triple = "x86_64-apple-macosx10.7.0"
;CHECK: store <2 x double> {{.*}}, !dbg ![[LOC2:[0-9]+]]
;CHECK: ret
;CHECK: ![[LOC]] = metadata !{i32 4, i32 0,
-;CHECK: ![[LOC2]] = metadata !{i32 7, i32 0,
+;CHECK: ![[LOC2]] = metadata !{i32 8, i32 0,
define i32 @depth(double* nocapture %A, i32 %m) #0 {
entry:
OpenPOWER on IntegriCloud