Home | History | Annotate | Download | only in LoopVectorize
      1 ; RUN: opt < %s -loop-vectorize -force-vector-width=4 -S -pass-remarks-missed='loop-vectorize' -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck %s
      2 
      3 ; CHECK: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
      4 ; CHECK: remark: source.cpp:4:5: loop not vectorized: vectorization is explicitly enabled with width 4
      5 
      6 ; CHECK: _Z11test_switchPii
      7 ; CHECK-NOT: x i32>
      8 ; CHECK: ret
      9 
     10 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
     11 
     12 ; Function Attrs: nounwind optsize ssp uwtable
     13 define void @_Z11test_switchPii(i32* nocapture %A, i32 %Length) #0 {
     14 entry:
     15   %cmp18 = icmp sgt i32 %Length, 0, !dbg !10
     16   br i1 %cmp18, label %for.body.preheader, label %for.end, !dbg !10, !llvm.loop !12
     17 
     18 for.body.preheader:                               ; preds = %entry
     19   br label %for.body, !dbg !14
     20 
     21 for.body:                                         ; preds = %for.body.preheader, %for.inc
     22   %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body.preheader ]
     23   %arrayidx = getelementptr inbounds i32* %A, i64 %indvars.iv, !dbg !14
     24   %0 = load i32* %arrayidx, align 4, !dbg !14, !tbaa !16
     25   switch i32 %0, label %for.inc [
     26     i32 0, label %sw.bb
     27     i32 1, label %sw.bb3
     28   ], !dbg !14
     29 
     30 sw.bb:                                            ; preds = %for.body
     31   %1 = trunc i64 %indvars.iv to i32, !dbg !20
     32   %mul = shl nsw i32 %1, 1, !dbg !20
     33   br label %for.inc, !dbg !22
     34 
     35 sw.bb3:                                           ; preds = %for.body
     36   %2 = trunc i64 %indvars.iv to i32, !dbg !23
     37   store i32 %2, i32* %arrayidx, align 4, !dbg !23, !tbaa !16
     38   br label %for.inc, !dbg !23
     39 
     40 for.inc:                                          ; preds = %sw.bb3, %for.body, %sw.bb
     41   %storemerge = phi i32 [ %mul, %sw.bb ], [ 0, %for.body ], [ 0, %sw.bb3 ]
     42   store i32 %storemerge, i32* %arrayidx, align 4, !dbg !20, !tbaa !16
     43   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10
     44   %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10
     45   %exitcond = icmp eq i32 %lftr.wideiv, %Length, !dbg !10
     46   br i1 %exitcond, label %for.end.loopexit, label %for.body, !dbg !10, !llvm.loop !12
     47 
     48 for.end.loopexit:                                 ; preds = %for.inc
     49   br label %for.end
     50 
     51 for.end:                                          ; preds = %for.end.loopexit, %entry
     52   ret void, !dbg !24
     53 }
     54 
     55 attributes #0 = { nounwind }
     56 
     57 !llvm.dbg.cu = !{!0}
     58 !llvm.module.flags = !{!7, !8}
     59 !llvm.ident = !{!9}
     60 
     61 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 2}
     62 !1 = metadata !{metadata !"source.cpp", metadata !"."}
     63 !2 = metadata !{}
     64 !3 = metadata !{metadata !4}
     65 !4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"test_switch", metadata !"test_switch", metadata !"", i32 1, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, void (i32*, i32)* @_Z11test_switchPii, null, null, metadata !2, i32 1}
     66 !5 = metadata !{i32 786473, metadata !1}
     67 !6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !2, i32 0, null, null, null}
     68 !7 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
     69 !8 = metadata !{i32 2, metadata !"Debug Info Version", i32 1}
     70 !9 = metadata !{metadata !"clang version 3.5.0"}
     71 !10 = metadata !{i32 3, i32 8, metadata !11, null}
     72 !11 = metadata !{i32 786443, metadata !1, metadata !4, i32 3, i32 3, i32 0, i32 0}
     73 !12 = metadata !{metadata !12, metadata !13, metadata !13}
     74 !13 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
     75 !14 = metadata !{i32 4, i32 5, metadata !15, null}
     76 !15 = metadata !{i32 786443, metadata !1, metadata !11, i32 3, i32 36, i32 0, i32 1}
     77 !16 = metadata !{metadata !17, metadata !17, i64 0}
     78 !17 = metadata !{metadata !"int", metadata !18, i64 0}
     79 !18 = metadata !{metadata !"omnipotent char", metadata !19, i64 0}
     80 !19 = metadata !{metadata !"Simple C/C++ TBAA"}
     81 !20 = metadata !{i32 6, i32 7, metadata !21, null}
     82 !21 = metadata !{i32 786443, metadata !1, metadata !15, i32 4, i32 18, i32 0, i32 2}
     83 !22 = metadata !{i32 7, i32 5, metadata !21, null}
     84 !23 = metadata !{i32 9, i32 7, metadata !21, null}
     85 !24 = metadata !{i32 14, i32 1, metadata !4, null}
     86