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