no_array_bounds.ll 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ; RUN: opt < %s -loop-vectorize -S 2>&1 | FileCheck %s
  2. ; Verify warning is generated when vectorization/ interleaving is explicitly specified and fails to occur.
  3. ; CHECK: warning: no_array_bounds.cpp:5:5: loop not vectorized: failed explicitly specified loop vectorization
  4. ; CHECK: warning: no_array_bounds.cpp:10:5: loop not interleaved: failed explicitly specified loop interleaving
  5. ; #pragma clang loop vectorize(enable)
  6. ; for (int i = 0; i < number; i++) {
  7. ; A[B[i]]++;
  8. ; }
  9. ; #pragma clang loop vectorize(disable) interleave(enable)
  10. ; for (int i = 0; i < number; i++) {
  11. ; B[A[i]]++;
  12. ; }
  13. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  14. ; Function Attrs: nounwind ssp uwtable
  15. define void @_Z4testPiS_i(i32* nocapture %A, i32* nocapture %B, i32 %number) #0 {
  16. entry:
  17. %cmp25 = icmp sgt i32 %number, 0, !dbg !10
  18. br i1 %cmp25, label %for.body.preheader, label %for.end15, !dbg !10, !llvm.loop !12
  19. for.body.preheader: ; preds = %entry
  20. br label %for.body, !dbg !14
  21. for.cond5.preheader: ; preds = %for.body
  22. br i1 %cmp25, label %for.body7.preheader, label %for.end15, !dbg !16, !llvm.loop !18
  23. for.body7.preheader: ; preds = %for.cond5.preheader
  24. br label %for.body7, !dbg !20
  25. for.body: ; preds = %for.body.preheader, %for.body
  26. %indvars.iv27 = phi i64 [ %indvars.iv.next28, %for.body ], [ 0, %for.body.preheader ]
  27. %arrayidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv27, !dbg !14
  28. %0 = load i32, i32* %arrayidx, align 4, !dbg !14, !tbaa !22
  29. %idxprom1 = sext i32 %0 to i64, !dbg !14
  30. %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %idxprom1, !dbg !14
  31. %1 = load i32, i32* %arrayidx2, align 4, !dbg !14, !tbaa !22
  32. %inc = add nsw i32 %1, 1, !dbg !14
  33. store i32 %inc, i32* %arrayidx2, align 4, !dbg !14, !tbaa !22
  34. %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1, !dbg !10
  35. %lftr.wideiv29 = trunc i64 %indvars.iv.next28 to i32, !dbg !10
  36. %exitcond30 = icmp eq i32 %lftr.wideiv29, %number, !dbg !10
  37. br i1 %exitcond30, label %for.cond5.preheader, label %for.body, !dbg !10, !llvm.loop !12
  38. for.body7: ; preds = %for.body7.preheader, %for.body7
  39. %indvars.iv = phi i64 [ %indvars.iv.next, %for.body7 ], [ 0, %for.body7.preheader ]
  40. %arrayidx9 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv, !dbg !20
  41. %2 = load i32, i32* %arrayidx9, align 4, !dbg !20, !tbaa !22
  42. %idxprom10 = sext i32 %2 to i64, !dbg !20
  43. %arrayidx11 = getelementptr inbounds i32, i32* %B, i64 %idxprom10, !dbg !20
  44. %3 = load i32, i32* %arrayidx11, align 4, !dbg !20, !tbaa !22
  45. %inc12 = add nsw i32 %3, 1, !dbg !20
  46. store i32 %inc12, i32* %arrayidx11, align 4, !dbg !20, !tbaa !22
  47. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !16
  48. %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !16
  49. %exitcond = icmp eq i32 %lftr.wideiv, %number, !dbg !16
  50. br i1 %exitcond, label %for.end15.loopexit, label %for.body7, !dbg !16, !llvm.loop !18
  51. for.end15.loopexit: ; preds = %for.body7
  52. br label %for.end15
  53. for.end15: ; preds = %for.end15.loopexit, %entry, %for.cond5.preheader
  54. ret void, !dbg !26
  55. }
  56. attributes #0 = { nounwind }
  57. !llvm.dbg.cu = !{!0}
  58. !llvm.module.flags = !{!7, !8}
  59. !llvm.ident = !{!9}
  60. !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0", isOptimized: true, emissionKind: 2, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
  61. !1 = !DIFile(filename: "no_array_bounds.cpp", directory: ".")
  62. !2 = !{}
  63. !3 = !{!4}
  64. !4 = !DISubprogram(name: "test", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 2, file: !1, scope: !5, type: !6, function: void (i32*, i32*, i32)* @_Z4testPiS_i, variables: !2)
  65. !5 = !DIFile(filename: "no_array_bounds.cpp", directory: ".")
  66. !6 = !DISubroutineType(types: !2)
  67. !7 = !{i32 2, !"Dwarf Version", i32 2}
  68. !8 = !{i32 2, !"Debug Info Version", i32 3}
  69. !9 = !{!"clang version 3.5.0"}
  70. !10 = !DILocation(line: 4, column: 8, scope: !11)
  71. !11 = distinct !DILexicalBlock(line: 4, column: 3, file: !1, scope: !4)
  72. !12 = !{!12, !13}
  73. !13 = !{!"llvm.loop.vectorize.enable", i1 true}
  74. !14 = !DILocation(line: 5, column: 5, scope: !15)
  75. !15 = distinct !DILexicalBlock(line: 4, column: 36, file: !1, scope: !11)
  76. !16 = !DILocation(line: 9, column: 8, scope: !17)
  77. !17 = distinct !DILexicalBlock(line: 9, column: 3, file: !1, scope: !4)
  78. !18 = !{!18, !13, !19}
  79. !19 = !{!"llvm.loop.vectorize.width", i32 1}
  80. !20 = !DILocation(line: 10, column: 5, scope: !21)
  81. !21 = distinct !DILexicalBlock(line: 9, column: 36, file: !1, scope: !17)
  82. !22 = !{!23, !23, i64 0}
  83. !23 = !{!"int", !24, i64 0}
  84. !24 = !{!"omnipotent char", !25, i64 0}
  85. !25 = !{!"Simple C/C++ TBAA"}
  86. !26 = !DILocation(line: 12, column: 1, scope: !4)