[llvm] r336667 - [DebugInfo][LoopVectorize] Preserve DL in induction PHI and Add

Anastasis Grammenos via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 10 06:29:50 PDT 2018


Author: gramanas
Date: Tue Jul 10 06:29:50 2018
New Revision: 336667

URL: http://llvm.org/viewvc/llvm-project?rev=336667&view=rev
Log:
[DebugInfo][LoopVectorize] Preserve DL in induction PHI and Add

Differential Revision: https://reviews.llvm.org/D48968

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
    llvm/trunk/test/Transforms/LoopVectorize/i8-induction.ll

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=336667&r1=336666&r2=336667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Jul 10 06:29:50 2018
@@ -1821,6 +1821,7 @@ void InnerLoopVectorizer::createVectorIn
   // factor. The last of those goes into the PHI.
   PHINode *VecInd = PHINode::Create(SteppedStart->getType(), 2, "vec.ind",
                                     &*LoopVectorBody->getFirstInsertionPt());
+  VecInd->setDebugLoc(EntryVal->getDebugLoc());
   Instruction *LastInduction = VecInd;
   for (unsigned Part = 0; Part < UF; ++Part) {
     VectorLoopValueMap.setVectorValue(EntryVal, Part, LastInduction);
@@ -1831,6 +1832,7 @@ void InnerLoopVectorizer::createVectorIn
 
     LastInduction = cast<Instruction>(addFastMathFlag(
         Builder.CreateBinOp(AddOp, LastInduction, SplatVF, "step.add")));
+    LastInduction->setDebugLoc(EntryVal->getDebugLoc());
   }
 
   // Move the last step to the end of the latch block. This ensures consistent

Modified: llvm/trunk/test/Transforms/LoopVectorize/i8-induction.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/i8-induction.ll?rev=336667&r1=336666&r2=336667&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/i8-induction.ll (original)
+++ llvm/trunk/test/Transforms/LoopVectorize/i8-induction.ll Tue Jul 10 06:29:50 2018
@@ -1,4 +1,5 @@
 ; RUN: opt < %s  -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S
+; RUN: opt < %s -debugify -loop-vectorize -S | FileCheck %s --check-prefix=DEBUGLOC
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
@@ -6,6 +7,12 @@ target datalayout = "e-p:64:64:64-i1:8:8
 @b = common global i8 0, align 1
 
 define void @f() nounwind uwtable ssp {
+; Check that the induction phis and adds have debug location.
+;
+; DEBUGLOC-LABEL: vector.body:
+; DEBUGLOC:         %vec.ind = phi {{.*}}, !dbg ![[DbgLoc:[0-9]+]]
+; DEBUGLOC:         %vec.ind.next = add {{.*}}, !dbg ![[DbgLoc]]
+
 scalar.ph:
   store i8 0, i8* inttoptr (i64 1 to i8*), align 1
   %0 = load i8, i8* @a, align 1
@@ -28,3 +35,6 @@ for.end:
   store i8 %mul, i8* @b, align 1
   ret void
 }
+
+; Check that the location of the new phi comes from %c.015 = phi i8
+; DEBUGLOC:         ![[DbgLoc]] = !DILocation(line: 5




More information about the llvm-commits mailing list