1*cee313d2SEric Christopher; RUN: opt < %s -loop-vectorize -force-vector-width=4 -transform-warning -S 2>&1 | FileCheck %s
2*cee313d2SEric Christopher; RUN: opt < %s -loop-vectorize -force-vector-width=1 -transform-warning -S 2>&1 | FileCheck %s -check-prefix=NOANALYSIS
3*cee313d2SEric Christopher; RUN: opt < %s -loop-vectorize -force-vector-width=4 -transform-warning -pass-remarks-missed='loop-vectorize' -S 2>&1 | FileCheck %s -check-prefix=MOREINFO
4*cee313d2SEric Christopher
5*cee313d2SEric Christopher; CHECK: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
6*cee313d2SEric Christopher; CHECK: 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
7*cee313d2SEric Christopher
8*cee313d2SEric Christopher; NOANALYSIS-NOT: remark: {{.*}}
9*cee313d2SEric Christopher; NOANALYSIS: 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*cee313d2SEric Christopher
11*cee313d2SEric Christopher; MOREINFO: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
12*cee313d2SEric Christopher; MOREINFO: remark: source.cpp:4:5: loop not vectorized (Force=true, Vector Width=4)
13*cee313d2SEric Christopher; MOREINFO: 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
14*cee313d2SEric Christopher
15*cee313d2SEric Christopher; CHECK: _Z11test_switchPii
16*cee313d2SEric Christopher; CHECK-NOT: x i32>
17*cee313d2SEric Christopher; CHECK: ret
18*cee313d2SEric Christopher
19*cee313d2SEric Christophertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
20*cee313d2SEric Christopher
21*cee313d2SEric Christopher; Function Attrs: nounwind optsize ssp uwtable
22*cee313d2SEric Christopherdefine void @_Z11test_switchPii(i32* nocapture %A, i32 %Length) #0 !dbg !4 {
23*cee313d2SEric Christopherentry:
24*cee313d2SEric Christopher  %cmp18 = icmp sgt i32 %Length, 0, !dbg !10
25*cee313d2SEric Christopher  br i1 %cmp18, label %for.body.preheader, label %for.end, !dbg !10, !llvm.loop !12
26*cee313d2SEric Christopher
27*cee313d2SEric Christopherfor.body.preheader:                               ; preds = %entry
28*cee313d2SEric Christopher  br label %for.body, !dbg !14
29*cee313d2SEric Christopher
30*cee313d2SEric Christopherfor.body:                                         ; preds = %for.body.preheader, %for.inc
31*cee313d2SEric Christopher  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body.preheader ]
32*cee313d2SEric Christopher  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv, !dbg !14
33*cee313d2SEric Christopher  %0 = load i32, i32* %arrayidx, align 4, !dbg !14, !tbaa !16
34*cee313d2SEric Christopher  switch i32 %0, label %for.inc [
35*cee313d2SEric Christopher    i32 0, label %sw.bb
36*cee313d2SEric Christopher    i32 1, label %sw.bb3
37*cee313d2SEric Christopher  ], !dbg !14
38*cee313d2SEric Christopher
39*cee313d2SEric Christophersw.bb:                                            ; preds = %for.body
40*cee313d2SEric Christopher  %1 = trunc i64 %indvars.iv to i32, !dbg !20
41*cee313d2SEric Christopher  %mul = shl nsw i32 %1, 1, !dbg !20
42*cee313d2SEric Christopher  br label %for.inc, !dbg !22
43*cee313d2SEric Christopher
44*cee313d2SEric Christophersw.bb3:                                           ; preds = %for.body
45*cee313d2SEric Christopher  %2 = trunc i64 %indvars.iv to i32, !dbg !23
46*cee313d2SEric Christopher  store i32 %2, i32* %arrayidx, align 4, !dbg !23, !tbaa !16
47*cee313d2SEric Christopher  br label %for.inc, !dbg !23
48*cee313d2SEric Christopher
49*cee313d2SEric Christopherfor.inc:                                          ; preds = %sw.bb3, %for.body, %sw.bb
50*cee313d2SEric Christopher  %storemerge = phi i32 [ %mul, %sw.bb ], [ 0, %for.body ], [ 0, %sw.bb3 ]
51*cee313d2SEric Christopher  store i32 %storemerge, i32* %arrayidx, align 4, !dbg !20, !tbaa !16
52*cee313d2SEric Christopher  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10
53*cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10
54*cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, %Length, !dbg !10
55*cee313d2SEric Christopher  br i1 %exitcond, label %for.end.loopexit, label %for.body, !dbg !10, !llvm.loop !12
56*cee313d2SEric Christopher
57*cee313d2SEric Christopherfor.end.loopexit:                                 ; preds = %for.inc
58*cee313d2SEric Christopher  br label %for.end
59*cee313d2SEric Christopher
60*cee313d2SEric Christopherfor.end:                                          ; preds = %for.end.loopexit, %entry
61*cee313d2SEric Christopher  ret void, !dbg !24
62*cee313d2SEric Christopher}
63*cee313d2SEric Christopher
64*cee313d2SEric Christopherattributes #0 = { nounwind }
65*cee313d2SEric Christopher
66*cee313d2SEric Christopher!llvm.dbg.cu = !{!0}
67*cee313d2SEric Christopher!llvm.module.flags = !{!7, !8}
68*cee313d2SEric Christopher!llvm.ident = !{!9}
69*cee313d2SEric Christopher
70*cee313d2SEric Christopher!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)
71*cee313d2SEric Christopher!1 = !DIFile(filename: "source.cpp", directory: ".")
72*cee313d2SEric Christopher!2 = !{}
73*cee313d2SEric Christopher!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)
74*cee313d2SEric Christopher!5 = !DIFile(filename: "source.cpp", directory: ".")
75*cee313d2SEric Christopher!6 = !DISubroutineType(types: !2)
76*cee313d2SEric Christopher!7 = !{i32 2, !"Dwarf Version", i32 2}
77*cee313d2SEric Christopher!8 = !{i32 2, !"Debug Info Version", i32 3}
78*cee313d2SEric Christopher!9 = !{!"clang version 3.5.0"}
79*cee313d2SEric Christopher!10 = !DILocation(line: 3, column: 8, scope: !11)
80*cee313d2SEric Christopher!11 = distinct !DILexicalBlock(line: 3, column: 3, file: !1, scope: !4)
81*cee313d2SEric Christopher!12 = !{!12, !13, !13}
82*cee313d2SEric Christopher!13 = !{!"llvm.loop.vectorize.enable", i1 true}
83*cee313d2SEric Christopher!14 = !DILocation(line: 4, column: 5, scope: !15)
84*cee313d2SEric Christopher!15 = distinct !DILexicalBlock(line: 3, column: 36, file: !1, scope: !11)
85*cee313d2SEric Christopher!16 = !{!17, !17, i64 0}
86*cee313d2SEric Christopher!17 = !{!"int", !18, i64 0}
87*cee313d2SEric Christopher!18 = !{!"omnipotent char", !19, i64 0}
88*cee313d2SEric Christopher!19 = !{!"Simple C/C++ TBAA"}
89*cee313d2SEric Christopher!20 = !DILocation(line: 6, column: 7, scope: !21)
90*cee313d2SEric Christopher!21 = distinct !DILexicalBlock(line: 4, column: 18, file: !1, scope: !15)
91*cee313d2SEric Christopher!22 = !DILocation(line: 7, column: 5, scope: !21)
92*cee313d2SEric Christopher!23 = !DILocation(line: 9, column: 7, scope: !21)
93*cee313d2SEric Christopher!24 = !DILocation(line: 14, column: 1, scope: !4)
94