brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 1675a59 Raw
111 lines · plain
1; RUN: opt -passes=loop-vectorize -force-vector-width=2 -S < %s | FileCheck %s2;3; Confirm that the DebugLoc info for the instructions in the middle block of a4; vectorized loop are correct. The Cmp and Br instructions should map to the5; same source lines as the Cmp and Br of the scalar loop.6 7; CHECK-LABEL: middle.block:8; CHECK-NEXT: [[CMP:%.*]] = icmp eq {{.*}}!dbg ![[DL:[0-9]+]]9; CHECK-NEXT: br i1 [[CMP]]{{.*}} !dbg ![[DL]]10; CHECK: ![[DL]] = !DILocation(line: 6,11 12; This IR can be generated by running:13; clang -g -O2 -emit-llvm -S -mllvm -opt-bisect-limit=68 vec.cpp -o - | opt -passes=loop-vectorize -force-vector-width=2 -S -o vec.ll14;15; Where vec.cpp contains:16;17; extern int x;18; extern int y;19; void a() {20;     const int len = x;21;     int b[len];22;     for(int i = 0; i< len; ++i)23;         b[i] = x;24;25;     y = b[x] + b[x-5];26; }27 28target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"29 30@"?x@@3HA" = external dso_local local_unnamed_addr global i32, align 431@"?y@@3HA" = external dso_local local_unnamed_addr global i32, align 432 33define dso_local void @"?a@@YAXXZ"() local_unnamed_addr #0 !dbg !8 {34entry:35  %0 = load i32, ptr @"?x@@3HA", align 4, !dbg !23, !tbaa !2436  %1 = zext i32 %0 to i64, !dbg !2837  %vla = alloca i32, i64 %1, align 16, !dbg !2838  %cmp10 = icmp sgt i32 %0, 0, !dbg !3039  br i1 %cmp10, label %for.body.preheader, label %for.cond.cleanup, !dbg !3040 41for.body.preheader:42  br label %for.body, !dbg !3143 44for.cond.cleanup.loopexit:45  %idxprom1.phi.trans.insert = sext i32 %0 to i6446  %arrayidx2.phi.trans.insert = getelementptr inbounds i32, ptr %vla, i64 %idxprom1.phi.trans.insert47  %.pre = load i32, ptr %arrayidx2.phi.trans.insert, align 4, !dbg !33, !tbaa !2448  br label %for.cond.cleanup, !dbg !3349 50for.cond.cleanup:51  %2 = phi i32 [ %.pre, %for.cond.cleanup.loopexit ], [ 0, %entry ], !dbg !3352  %sub = add nsw i32 %0, -5, !dbg !3353  %idxprom3 = sext i32 %sub to i64, !dbg !3354  %arrayidx4 = getelementptr inbounds i32, ptr %vla, i64 %idxprom3, !dbg !3355  %3 = load i32, ptr %arrayidx4, align 4, !dbg !33, !tbaa !2456  %add = add nsw i32 %3, %2, !dbg !3357  store i32 %add, ptr @"?y@@3HA", align 4, !dbg !33, !tbaa !2458  ret void, !dbg !3459 60for.body:61  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]62  %arrayidx = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv, !dbg !3163  store i32 %0, ptr %arrayidx, align 4, !dbg !31, !tbaa !2464  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !3565  %exitcond = icmp eq i64 %indvars.iv.next, %1, !dbg !3066  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !30, !llvm.loop !3667}68 69!llvm.dbg.cu = !{!0}70!llvm.module.flags = !{!3, !4, !5, !6}71!llvm.ident = !{!7}72 73!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 045b8544fd2c4e14f7e72e0df2bc681d823b0838)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)74!1 = !DIFile(filename: "vec.cpp", directory: "C:\5CUsers\5Cgbhyamso\5Cdev\5Cllvm\5Csamples", checksumkind: CSK_MD5, checksum: "fed997f50117f5514a69caf1c2fb2c49")75!2 = !{}76!3 = !{i32 2, !"CodeView", i32 1}77!4 = !{i32 2, !"Debug Info Version", i32 3}78!5 = !{i32 1, !"wchar_size", i32 2}79!6 = !{i32 7, !"PIC Level", i32 2}80!7 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 045b8544fd2c4e14f7e72e0df2bc681d823b0838)"}81!8 = distinct !DISubprogram(name: "a", linkageName: "?a@@YAXXZ", scope: !1, file: !1, line: 3, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)82!9 = !DISubroutineType(types: !10)83!10 = !{null}84!11 = !{!12, !15, !17, !21}85!12 = !DILocalVariable(name: "len", scope: !8, file: !1, line: 4, type: !13)86!13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)87!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)88!15 = !DILocalVariable(name: "__vla_expr0", scope: !8, type: !16, flags: DIFlagArtificial)89!16 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)90!17 = !DILocalVariable(name: "b", scope: !8, file: !1, line: 5, type: !18)91!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !14, elements: !19)92!19 = !{!20}93!20 = !DISubrange(count: !15)94!21 = !DILocalVariable(name: "i", scope: !22, file: !1, line: 6, type: !14)95!22 = distinct !DILexicalBlock(scope: !8, file: !1, line: 6)96!23 = !DILocation(line: 4, scope: !8)97!24 = !{!25, !25, i64 0}98!25 = !{!"int", !26, i64 0}99!26 = !{!"omnipotent char", !27, i64 0}100!27 = !{!"Simple C++ TBAA"}101!28 = !DILocation(line: 5, scope: !8)102!29 = !DILocation(line: 0, scope: !8)103!30 = !DILocation(line: 6, scope: !22)104!31 = !DILocation(line: 7, scope: !32)105!32 = distinct !DILexicalBlock(scope: !22, file: !1, line: 6)106!33 = !DILocation(line: 9, scope: !8)107!34 = !DILocation(line: 10, scope: !8)108!35 = !DILocation(line: 6, scope: !32)109!36 = distinct !{!36, !30, !37}110!37 = !DILocation(line: 7, scope: !22)111