no_switch.ll 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. ; CHECK: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
  3. ; CHECK: remark: source.cpp:4:5: loop not vectorized: use -Rpass-analysis=loop-vectorize for more info (Force=true, Vector Width=4)
  4. ; CHECK: warning: source.cpp:4:5: loop not vectorized: failed explicitly specified loop vectorization
  5. ; CHECK: _Z11test_switchPii
  6. ; CHECK-NOT: x i32>
  7. ; CHECK: ret
  8. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  9. ; Function Attrs: nounwind optsize ssp uwtable
  10. define void @_Z11test_switchPii(i32* nocapture %A, i32 %Length) #0 {
  11. entry:
  12. %cmp18 = icmp sgt i32 %Length, 0, !dbg !10
  13. br i1 %cmp18, label %for.body.preheader, label %for.end, !dbg !10, !llvm.loop !12
  14. for.body.preheader: ; preds = %entry
  15. br label %for.body, !dbg !14
  16. for.body: ; preds = %for.body.preheader, %for.inc
  17. %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body.preheader ]
  18. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv, !dbg !14
  19. %0 = load i32, i32* %arrayidx, align 4, !dbg !14, !tbaa !16
  20. switch i32 %0, label %for.inc [
  21. i32 0, label %sw.bb
  22. i32 1, label %sw.bb3
  23. ], !dbg !14
  24. sw.bb: ; preds = %for.body
  25. %1 = trunc i64 %indvars.iv to i32, !dbg !20
  26. %mul = shl nsw i32 %1, 1, !dbg !20
  27. br label %for.inc, !dbg !22
  28. sw.bb3: ; preds = %for.body
  29. %2 = trunc i64 %indvars.iv to i32, !dbg !23
  30. store i32 %2, i32* %arrayidx, align 4, !dbg !23, !tbaa !16
  31. br label %for.inc, !dbg !23
  32. for.inc: ; preds = %sw.bb3, %for.body, %sw.bb
  33. %storemerge = phi i32 [ %mul, %sw.bb ], [ 0, %for.body ], [ 0, %sw.bb3 ]
  34. store i32 %storemerge, i32* %arrayidx, align 4, !dbg !20, !tbaa !16
  35. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10
  36. %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10
  37. %exitcond = icmp eq i32 %lftr.wideiv, %Length, !dbg !10
  38. br i1 %exitcond, label %for.end.loopexit, label %for.body, !dbg !10, !llvm.loop !12
  39. for.end.loopexit: ; preds = %for.inc
  40. br label %for.end
  41. for.end: ; preds = %for.end.loopexit, %entry
  42. ret void, !dbg !24
  43. }
  44. attributes #0 = { nounwind }
  45. !llvm.dbg.cu = !{!0}
  46. !llvm.module.flags = !{!7, !8}
  47. !llvm.ident = !{!9}
  48. !0 = !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)
  49. !1 = !DIFile(filename: "source.cpp", directory: ".")
  50. !2 = !{}
  51. !3 = !{!4}
  52. !4 = !DISubprogram(name: "test_switch", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 1, file: !1, scope: !5, type: !6, function: void (i32*, i32)* @_Z11test_switchPii, variables: !2)
  53. !5 = !DIFile(filename: "source.cpp", directory: ".")
  54. !6 = !DISubroutineType(types: !2)
  55. !7 = !{i32 2, !"Dwarf Version", i32 2}
  56. !8 = !{i32 2, !"Debug Info Version", i32 3}
  57. !9 = !{!"clang version 3.5.0"}
  58. !10 = !DILocation(line: 3, column: 8, scope: !11)
  59. !11 = distinct !DILexicalBlock(line: 3, column: 3, file: !1, scope: !4)
  60. !12 = !{!12, !13, !13}
  61. !13 = !{!"llvm.loop.vectorize.enable", i1 true}
  62. !14 = !DILocation(line: 4, column: 5, scope: !15)
  63. !15 = distinct !DILexicalBlock(line: 3, column: 36, file: !1, scope: !11)
  64. !16 = !{!17, !17, i64 0}
  65. !17 = !{!"int", !18, i64 0}
  66. !18 = !{!"omnipotent char", !19, i64 0}
  67. !19 = !{!"Simple C/C++ TBAA"}
  68. !20 = !DILocation(line: 6, column: 7, scope: !21)
  69. !21 = distinct !DILexicalBlock(line: 4, column: 18, file: !1, scope: !15)
  70. !22 = !DILocation(line: 7, column: 5, scope: !21)
  71. !23 = !DILocation(line: 9, column: 7, scope: !21)
  72. !24 = !DILocation(line: 14, column: 1, scope: !4)