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