1; RUN: opt -passes=loop-vectorize -pass-remarks-analysis=loop-vectorize < %s 2>&1 | FileCheck %s 2 3; 1 extern int map[]; 4; 2 extern int out[]; 5; 3 6; 4 void f(int a, int n) { 7; 5 for (int i = 0; i < n; ++i) { 8; 6 out[i] = a; 9; 7 a = map[a]; 10; 8 } 11; 9 } 12 13; CHECK: remark: /tmp/s.c:5:3: loop not vectorized: value that could not be identified as reduction is used outside the loop 14 15; %a.addr.08 is the phi corresponding to the remark. It does not have debug 16; location attached. In this case we should use the debug location of the 17; loop rather than emitting <unknown>:0:0: 18 19; ModuleID = '/tmp/s.c' 20source_filename = "/tmp/s.c" 21target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 22 23@out = external local_unnamed_addr global [0 x i32], align 4 24@map = external local_unnamed_addr global [0 x i32], align 4 25 26; Function Attrs: norecurse nounwind ssp uwtable 27define void @f(i32 %a, i32 %n) local_unnamed_addr #0 !dbg !6 { 28entry: 29 %cmp7 = icmp sgt i32 %n, 0, !dbg !8 30 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup, !dbg !9 31 32for.body.preheader: ; preds = %entry 33 %wide.trip.count = zext i32 %n to i64, !dbg !9 34 br label %for.body, !dbg !10 35 36for.cond.cleanup: ; preds = %for.body, %entry 37 ret void, !dbg !11 38 39for.body: ; preds = %for.body.preheader, %for.body 40 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ] 41 %a.addr.08 = phi i32 [ %0, %for.body ], [ %a, %for.body.preheader ] 42 43 %arrayidx = getelementptr inbounds [0 x i32], ptr @out, i64 0, i64 %indvars.iv, !dbg !10 44 store i32 %a.addr.08, ptr %arrayidx, align 4, !dbg !12, !tbaa !13 45 %idxprom1 = sext i32 %a.addr.08 to i64, !dbg !17 46 %arrayidx2 = getelementptr inbounds [0 x i32], ptr @map, i64 0, i64 %idxprom1, !dbg !17 47 %0 = load i32, ptr %arrayidx2, align 4, !dbg !17, !tbaa !13 48 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !9 49 %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count, !dbg !9 50 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !9, !llvm.loop !18 51} 52 53attributes #0 = { norecurse nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="core2" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 54 55!llvm.dbg.cu = !{!0} 56!llvm.module.flags = !{!3, !4} 57!llvm.ident = !{!5} 58 59!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 281293) (llvm/trunk 281290)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) 60!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp") 61!2 = !{} 62!3 = !{i32 2, !"Debug Info Version", i32 3} 63!4 = !{i32 1, !"PIC Level", i32 2} 64!5 = !{!"clang version 4.0.0 (trunk 281293) (llvm/trunk 281290)"} 65!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 66!7 = !DISubroutineType(types: !2) 67!8 = !DILocation(line: 5, column: 21, scope: !6) 68!9 = !DILocation(line: 5, column: 3, scope: !6) 69!10 = !DILocation(line: 6, column: 5, scope: !6) 70!11 = !DILocation(line: 9, column: 1, scope: !6) 71!12 = !DILocation(line: 6, column: 12, scope: !6) 72!13 = !{!14, !14, i64 0} 73!14 = !{!"int", !15, i64 0} 74!15 = !{!"omnipotent char", !16, i64 0} 75!16 = !{!"Simple C/C++ TBAA"} 76!17 = !DILocation(line: 7, column: 9, scope: !6) 77!18 = distinct !{!18, !9} 78