diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2013-03-09 15:56:34 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2013-03-09 15:56:34 +0000 |
commit | 56ee544a3af2b019329f06422c00e8a3645b895c (patch) | |
tree | 0efec4dc4ae78b20245437f37c4698ef75b98dac | |
parent | 576f62c1ead0c099aacf2bc08552a1348d57c23f (diff) | |
download | external_llvm-56ee544a3af2b019329f06422c00e8a3645b895c.zip external_llvm-56ee544a3af2b019329f06422c00e8a3645b895c.tar.gz external_llvm-56ee544a3af2b019329f06422c00e8a3645b895c.tar.bz2 |
LoopVectorizer: Ignore dbg.value instructions
We want vectorization to happen at -g. Ignore calls to the dbg.value intrinsic
and don't transfer them to the vectorized code.
radar://13378964
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176768 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Vectorize/LoopVectorize.cpp | 13 | ||||
-rw-r--r-- | test/Transforms/LoopVectorize/dbg.value.ll | 70 |
2 files changed, 81 insertions, 2 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index 11f4b02..e1f2932 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2088,6 +2088,10 @@ InnerLoopVectorizer::vectorizeBlockInLoop(LoopVectorizationLegality *Legal, } case Instruction::Call: { + // Ignore dbg.value instructions. + if (isa<DbgValueInst>(it)) + break; + Module *M = BB->getParent()->getParent(); CallInst *CI = cast<CallInst>(it); Intrinsic::ID ID = getIntrinsicIDForCall(CI, TLI); @@ -2324,9 +2328,10 @@ bool LoopVectorizationLegality::canVectorizeInstrs() { return false; }// end of PHI handling - // We still don't handle functions. + // We still don't handle functions. However, we can ignore dbg.value + // calls and we do handle certain intrinsic and libm functions. CallInst *CI = dyn_cast<CallInst>(it); - if (CI && !getIntrinsicIDForCall(CI, TLI)) { + if (CI && !getIntrinsicIDForCall(CI, TLI) && !isa<DbgValueInst>(CI)) { DEBUG(dbgs() << "LV: Found a call site.\n"); return false; } @@ -3263,6 +3268,10 @@ unsigned LoopVectorizationCostModel::expectedCost(unsigned VF) { // For each instruction in the old loop. for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) { + // Skip dbg.value instructions. + if (isa<DbgValueInst>(it)) + continue; + unsigned C = getInstructionCost(it, VF); Cost += C; DEBUG(dbgs() << "LV: Found an estimated cost of "<< C <<" for VF " << diff --git a/test/Transforms/LoopVectorize/dbg.value.ll b/test/Transforms/LoopVectorize/dbg.value.ll new file mode 100644 index 0000000..a2ea951 --- /dev/null +++ b/test/Transforms/LoopVectorize/dbg.value.ll @@ -0,0 +1,70 @@ +; RUN: opt < %s -S -loop-vectorize -force-vector-unroll=1 -force-vector-width=4 -dce -instcombine | FileCheck %s +; Make sure we vectorize with debugging turned on. + +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" +target triple = "x86_64-apple-macosx10.8.0" + +@A = global [1024 x i32] zeroinitializer, align 16 +@B = global [1024 x i32] zeroinitializer, align 16 +@C = global [1024 x i32] zeroinitializer, align 16 + +; CHECK: @test +define i32 @test() #0 { +entry: + tail call void @llvm.dbg.value(metadata !1, i64 0, metadata !9), !dbg !18 + br label %for.body, !dbg !18 + +for.body: + ;CHECK: load <4 x i32> + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %arrayidx = getelementptr inbounds [1024 x i32]* @B, i64 0, i64 %indvars.iv, !dbg !19 + %0 = load i32* %arrayidx, align 4, !dbg !19, !tbaa !21 + %arrayidx2 = getelementptr inbounds [1024 x i32]* @C, i64 0, i64 %indvars.iv, !dbg !19 + %1 = load i32* %arrayidx2, align 4, !dbg !19, !tbaa !21 + %add = add nsw i32 %1, %0, !dbg !19 + %arrayidx4 = getelementptr inbounds [1024 x i32]* @A, i64 0, i64 %indvars.iv, !dbg !19 + store i32 %add, i32* %arrayidx4, align 4, !dbg !19, !tbaa !21 + %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !18 + tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !9), !dbg !18 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !18 + %exitcond = icmp ne i32 %lftr.wideiv, 1024, !dbg !18 + br i1 %exitcond, label %for.body, label %for.end, !dbg !18 + +for.end: + ret i32 0, !dbg !24 +} + +declare void @llvm.dbg.declare(metadata, metadata) #1 + +declare void @llvm.dbg.value(metadata, i64, metadata) #1 + +attributes #0 = { nounwind ssp uwtable "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, i32 0, i32 4, metadata !"test", metadata !"/path/to/somewhere", metadata !"clang", i1 true, i1 true, metadata !"", i32 0, metadata !1, metadata !1, metadata !2, metadata !11, metadata !""} +!1 = metadata !{i32 0} +!2 = metadata !{metadata !3} +!3 = metadata !{i32 786478, i32 0, metadata !4, metadata !"test", metadata !"test", metadata !"test", metadata !4, i32 5, metadata !5, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, i32 ()* @test, null, null, metadata !8, i32 5} +!4 = metadata !{i32 786473, metadata !"test", metadata !"/path/to/somewhere", null} +!5 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !6, i32 0, i32 0} +!6 = metadata !{metadata !7} +!7 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} +!8 = metadata !{metadata !9} +!9 = metadata !{i32 786688, metadata !10, metadata !"i", metadata !4, i32 6, metadata !7, i32 0, i32 0} +!10 = metadata !{i32 786443, metadata !3, i32 6, i32 0, metadata !4, i32 0} +!11 = metadata !{metadata !12, metadata !16, metadata !17} +!12 = metadata !{i32 786484, i32 0, null, metadata !"A", metadata !"A", metadata !"", metadata !4, i32 1, metadata !13, i32 0, i32 1, [1024 x i32]* @A, null} +!13 = metadata !{i32 786433, null, metadata !"", null, i32 0, i64 32768, i64 32, i32 0, i32 0, metadata !7, metadata !14, i32 0, i32 0} +!14 = metadata !{metadata !15} +!15 = metadata !{i32 786465, i64 0, i64 1024} +!16 = metadata !{i32 786484, i32 0, null, metadata !"B", metadata !"B", metadata !"", metadata !4, i32 2, metadata !13, i32 0, i32 1, [1024 x i32]* @B, null} +!17 = metadata !{i32 786484, i32 0, null, metadata !"C", metadata !"C", metadata !"", metadata !4, i32 3, metadata !13, i32 0, i32 1, [1024 x i32]* @C, null} +!18 = metadata !{i32 6, i32 0, metadata !10, null} +!19 = metadata !{i32 7, i32 0, metadata !20, null} +!20 = metadata !{i32 786443, metadata !10, i32 6, i32 0, metadata !4, i32 1} +!21 = metadata !{metadata !"int", metadata !22} +!22 = metadata !{metadata !"omnipotent char", metadata !23} +!23 = metadata !{metadata !"Simple C/C++ TBAA"} +!24 = metadata !{i32 9, i32 0, metadata !3, null} |