1; RUN: opt < %s -passes=loop-vectorize,transform-warning -force-vector-width=4 -S 2>&1 | FileCheck %s 2; RUN: opt < %s -passes=loop-vectorize,transform-warning -force-vector-width=1 -S 2>&1 | FileCheck %s -check-prefix=NOANALYSIS 3; RUN: opt < %s -passes=loop-vectorize,transform-warning -force-vector-width=4 -pass-remarks-missed='loop-vectorize' -S 2>&1 | FileCheck %s -check-prefix=MOREINFO 4 5; This test is a copy of no_switch.ll, with the "llvm.loop.vectorize.enable" metadata set to false. 6; It tests that vectorization is explicitly disabled and no warnings are emitted. 7 8; CHECK-NOT: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement 9; CHECK-NOT: warning: source.cpp:4:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering 10 11; NOANALYSIS-NOT: remark: {{.*}} 12; NOANALYSIS-NOT: warning: source.cpp:4:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering 13 14; MOREINFO: remark: source.cpp:4:5: loop not vectorized: vectorization is explicitly disabled 15; MOREINFO-NOT: warning: source.cpp:4:5: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering 16 17; CHECK: _Z11test_switchPii 18; CHECK-NOT: x i32> 19; CHECK: ret 20 21target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 22 23; Function Attrs: nounwind optsize ssp uwtable 24define void @_Z11test_switchPii(ptr nocapture %A, i32 %Length) #0 !dbg !4 { 25entry: 26 %cmp18 = icmp sgt i32 %Length, 0, !dbg !10 27 br i1 %cmp18, label %for.body.preheader, label %for.end, !dbg !10, !llvm.loop !12 28 29for.body.preheader: ; preds = %entry 30 br label %for.body, !dbg !14 31 32for.body: ; preds = %for.body.preheader, %for.inc 33 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body.preheader ] 34 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv, !dbg !14 35 %0 = load i32, ptr %arrayidx, align 4, !dbg !14, !tbaa !16 36 switch i32 %0, label %for.inc [ 37 i32 0, label %sw.bb 38 i32 1, label %sw.bb3 39 ], !dbg !14 40 41sw.bb: ; preds = %for.body 42 %1 = trunc i64 %indvars.iv to i32, !dbg !20 43 %mul = shl nsw i32 %1, 1, !dbg !20 44 br label %for.inc, !dbg !22 45 46sw.bb3: ; preds = %for.body 47 %2 = trunc i64 %indvars.iv to i32, !dbg !23 48 store i32 %2, ptr %arrayidx, align 4, !dbg !23, !tbaa !16 49 br label %for.inc, !dbg !23 50 51for.inc: ; preds = %sw.bb3, %for.body, %sw.bb 52 %storemerge = phi i32 [ %mul, %sw.bb ], [ 0, %for.body ], [ 0, %sw.bb3 ] 53 store i32 %storemerge, ptr %arrayidx, align 4, !dbg !20, !tbaa !16 54 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10 55 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10 56 %exitcond = icmp eq i32 %lftr.wideiv, %Length, !dbg !10 57 br i1 %exitcond, label %for.end.loopexit, label %for.body, !dbg !10, !llvm.loop !12 58 59for.end.loopexit: ; preds = %for.inc 60 br label %for.end 61 62for.end: ; preds = %for.end.loopexit, %entry 63 ret void, !dbg !24 64} 65 66attributes #0 = { nounwind } 67 68!llvm.dbg.cu = !{!0} 69!llvm.module.flags = !{!7, !8} 70!llvm.ident = !{!9} 71 72!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0", isOptimized: true, runtimeVersion: 6, emissionKind: LineTablesOnly, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 73!1 = !DIFile(filename: "source.cpp", directory: ".") 74!2 = !{} 75!4 = distinct !DISubprogram(name: "test_switch", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2) 76!5 = !DIFile(filename: "source.cpp", directory: ".") 77!6 = !DISubroutineType(types: !2) 78!7 = !{i32 2, !"Dwarf Version", i32 2} 79!8 = !{i32 2, !"Debug Info Version", i32 3} 80!9 = !{!"clang version 3.5.0"} 81!10 = !DILocation(line: 3, column: 8, scope: !11) 82!11 = distinct !DILexicalBlock(line: 3, column: 3, file: !1, scope: !4) 83!12 = !{!12, !13, !13} 84!13 = !{!"llvm.loop.vectorize.enable", i1 false} 85!14 = !DILocation(line: 4, column: 5, scope: !15) 86!15 = distinct !DILexicalBlock(line: 3, column: 36, file: !1, scope: !11) 87!16 = !{!17, !17, i64 0} 88!17 = !{!"int", !18, i64 0} 89!18 = !{!"omnipotent char", !19, i64 0} 90!19 = !{!"Simple C/C++ TBAA"} 91!20 = !DILocation(line: 6, column: 7, scope: !21) 92!21 = distinct !DILexicalBlock(line: 4, column: 18, file: !1, scope: !15) 93!22 = !DILocation(line: 7, column: 5, scope: !21) 94!23 = !DILocation(line: 9, column: 7, scope: !21) 95!24 = !DILocation(line: 14, column: 1, scope: !4) 96