<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">LGTM. Thanks for working on it.  :)<div><br><div><div>On Aug 26, 2013, at 3:49 PM, Matt Arsenault <<a href="mailto:Matthew.Arsenault@amd.com">Matthew.Arsenault@amd.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> Use first item as debug location, and update test<br><br>Hi nadav,<br><br><a href="http://llvm-reviews.chandlerc.com/D1518">http://llvm-reviews.chandlerc.com/D1518</a><br><br>CHANGE SINCE LAST DIFF<br> <a href="http://llvm-reviews.chandlerc.com/D1518?vs=3759&id=3772#toc">http://llvm-reviews.chandlerc.com/D1518?vs=3759&id=3772#toc</a><br><br>Files:<br> lib/Transforms/Vectorize/SLPVectorizer.cpp<br> test/Transforms/SLPVectorizer/X86/debug_info.ll<br><br>Index: lib/Transforms/Vectorize/SLPVectorizer.cpp<br>===================================================================<br>--- lib/Transforms/Vectorize/SLPVectorizer.cpp<br>+++ lib/Transforms/Vectorize/SLPVectorizer.cpp<br>@@ -311,6 +311,10 @@<br>  /// \returns the Instruction in the bundle \p VL.<br>  Instruction *getLastInstruction(ArrayRef<Value *> VL);<br><br>+  /// \brief Set the Builder insert point to one after the last instruction in<br>+  /// the bundle<br>+  void setInsertPointAfterBundle(ArrayRef<Value *> VL);<br>+<br>  /// \returns a vector from a collection of scalars in \p VL.<br>  Value *Gather(ArrayRef<Value *> VL, VectorType *Ty);<br><br>@@ -1068,6 +1072,15 @@<br>  return I;<br>}<br><br>+void BoUpSLP::setInsertPointAfterBundle(ArrayRef<Value *> VL) {<br>+  Instruction *VL0 = cast<Instruction>(VL[0]);<br>+  Instruction *LastInst = getLastInstruction(VL);<br>+  BasicBlock::iterator NextInst = LastInst;<br>+  ++NextInst;<br>+  Builder.SetInsertPoint(VL0->getParent(), NextInst);<br>+  Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+}<br>+<br>Value *BoUpSLP::Gather(ArrayRef<Value *> VL, VectorType *Ty) {<br>  Value *Vec = UndefValue::get(Ty);<br>  // Generate the 'InsertElement' instruction.<br>@@ -1141,10 +1154,7 @@<br>  VectorType *VecTy = VectorType::get(ScalarTy, E->Scalars.size());<br><br>  if (E->NeedToGather) {<br>-    BasicBlock::iterator NextInst = getLastInstruction(E->Scalars);<br>-    ++NextInst;<br>-    assert(NextInst != VL0->getParent()->end());<br>-    Builder.SetInsertPoint(NextInst);<br>+    setInsertPointAfterBundle(E->Scalars);<br>    return Gather(E->Scalars, VecTy);<br>  }<br><br>@@ -1212,8 +1222,7 @@<br>      for (int i = 0, e = E->Scalars.size(); i < e; ++i)<br>        INVL.push_back(cast<Instruction>(E->Scalars[i])->getOperand(0));<br><br>-      Builder.SetInsertPoint(getLastInstruction(E->Scalars));<br>-      Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+      setInsertPointAfterBundle(E->Scalars);<br><br>      Value *InVec = vectorizeTree(INVL);<br><br>@@ -1233,8 +1242,7 @@<br>        RHSV.push_back(cast<Instruction>(E->Scalars[i])->getOperand(1));<br>      }<br><br>-      Builder.SetInsertPoint(getLastInstruction(E->Scalars));<br>-      Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+      setInsertPointAfterBundle(E->Scalars);<br><br>      Value *L = vectorizeTree(LHSV);<br>      Value *R = vectorizeTree(RHSV);<br>@@ -1260,8 +1268,7 @@<br>        FalseVec.push_back(cast<Instruction>(E->Scalars[i])->getOperand(2));<br>      }<br><br>-      Builder.SetInsertPoint(getLastInstruction(E->Scalars));<br>-      Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+      setInsertPointAfterBundle(E->Scalars);<br><br>      Value *Cond = vectorizeTree(CondVec);<br>      Value *True = vectorizeTree(TrueVec);<br>@@ -1298,8 +1305,7 @@<br>        RHSVL.push_back(cast<Instruction>(E->Scalars[i])->getOperand(1));<br>      }<br><br>-      Builder.SetInsertPoint(getLastInstruction(E->Scalars));<br>-      Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+      setInsertPointAfterBundle(E->Scalars);<br><br>      Value *LHS = vectorizeTree(LHSVL);<br>      Value *RHS = vectorizeTree(RHSVL);<br>@@ -1319,8 +1325,7 @@<br>    case Instruction::Load: {<br>      // Loads are inserted at the head of the tree because we don't want to<br>      // sink them all the way down past store instructions.<br>-      Builder.SetInsertPoint(getLastInstruction(E->Scalars));<br>-      Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+      setInsertPointAfterBundle(E->Scalars);<br><br>      LoadInst *LI = cast<LoadInst>(VL0);<br>      Value *VecPtr =<br>@@ -1339,8 +1344,7 @@<br>      for (int i = 0, e = E->Scalars.size(); i < e; ++i)<br>        ValueOp.push_back(cast<StoreInst>(E->Scalars[i])->getValueOperand());<br><br>-      Builder.SetInsertPoint(getLastInstruction(E->Scalars));<br>-      Builder.SetCurrentDebugLocation(VL0->getDebugLoc());<br>+      setInsertPointAfterBundle(E->Scalars);<br><br>      Value *VecValue = vectorizeTree(ValueOp);<br>      Value *VecPtr =<br>Index: test/Transforms/SLPVectorizer/X86/debug_info.ll<br>===================================================================<br>--- test/Transforms/SLPVectorizer/X86/debug_info.ll<br>+++ test/Transforms/SLPVectorizer/X86/debug_info.ll<br>@@ -19,7 +19,7 @@<br>;CHECK: store <2 x double> {{.*}}, !dbg ![[LOC2:[0-9]+]]<br>;CHECK: ret<br>;CHECK: ![[LOC]] = metadata !{i32 4, i32 0,<br>-;CHECK: ![[LOC2]] = metadata !{i32 7, i32 0,<br>+;CHECK: ![[LOC2]] = metadata !{i32 8, i32 0,<br><br>define i32 @depth(double* nocapture %A, i32 %m) #0 {<br>entry:<br><span><D1518.2.patch></span></div></blockquote></div><br></div></body></html>