[opaque pointer type] Add textual IR support for explicit type parameter to getelemen...
[oota-llvm.git] / test / Transforms / LoopVectorize / X86 / vectorization-remarks-missed.ll
1 ; RUN: opt < %s -loop-vectorize -S -pass-remarks-missed='loop-vectorize' -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck %s
2
3 ; C/C++ code for tests
4 ; void test(int *A, int Length) {
5 ; #pragma clang loop vectorize(enable) interleave(enable)
6 ;   for (int i = 0; i < Length; i++) {
7 ;     A[i] = i;
8 ;     if (A[i] > Length)
9 ;       break;
10 ;   }
11 ; }
12
13 ; void test_disabled(int *A, int Length) {
14 ; #pragma clang loop vectorize(disable) interleave(disable)
15 ;   for (int i = 0; i < Length; i++)
16 ;     A[i] = i;
17 ; }
18
19 ; void test_array_bounds(int *A, int *B, int Length) {
20 ; #pragma clang loop vectorize(enable)
21 ;   for (int i = 0; i < Length; i++)
22 ;     A[i] = A[B[i]];
23 ; }
24
25 ; File, line, and column should match those specified in the metadata
26 ; CHECK: remark: source.cpp:4:5: loop not vectorized: could not determine number of loop iterations
27 ; CHECK: remark: source.cpp:4:5: loop not vectorized: use -Rpass-analysis=loop-vectorize for more info
28 ; CHECK: remark: source.cpp:13:5: loop not vectorized: vector width and interleave count are explicitly set to 1
29 ; CHECK: remark: source.cpp:19:5: loop not vectorized: cannot identify array bounds
30 ; CHECK: remark: source.cpp:19:5: loop not vectorized: use -Rpass-analysis=loop-vectorize for more info
31 ; CHECK: warning: source.cpp:19:5: loop not vectorized: failed explicitly specified loop vectorization
32
33 ; CHECK: _Z4testPii
34 ; CHECK-NOT: x i32>
35 ; CHECK: ret
36
37 ; CHECK: _Z13test_disabledPii
38 ; CHECK-NOT: x i32>
39 ; CHECK: ret
40
41 ; CHECK: _Z17test_array_boundsPiS_i
42 ; CHECK-NOT: x i32>
43 ; CHECK: ret
44
45 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
46
47 ; Function Attrs: nounwind optsize ssp uwtable
48 define void @_Z4testPii(i32* nocapture %A, i32 %Length) #0 {
49 entry:
50   %cmp10 = icmp sgt i32 %Length, 0, !dbg !12
51   br i1 %cmp10, label %for.body, label %for.end, !dbg !12, !llvm.loop !14
52
53 for.body:                                         ; preds = %entry, %for.body
54   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
55   %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv, !dbg !16
56   %0 = trunc i64 %indvars.iv to i32, !dbg !16
57   store i32 %0, i32* %arrayidx, align 4, !dbg !16, !tbaa !18
58   %cmp3 = icmp sle i32 %0, %Length, !dbg !22
59   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !12
60   %1 = trunc i64 %indvars.iv.next to i32
61   %cmp = icmp slt i32 %1, %Length, !dbg !12
62   %or.cond = and i1 %cmp3, %cmp, !dbg !22
63   br i1 %or.cond, label %for.body, label %for.end, !dbg !22
64
65 for.end:                                          ; preds = %for.body, %entry
66   ret void, !dbg !24
67 }
68
69 ; Function Attrs: nounwind optsize ssp uwtable
70 define void @_Z13test_disabledPii(i32* nocapture %A, i32 %Length) #0 {
71 entry:
72   %cmp4 = icmp sgt i32 %Length, 0, !dbg !25
73   br i1 %cmp4, label %for.body, label %for.end, !dbg !25, !llvm.loop !27
74
75 for.body:                                         ; preds = %entry, %for.body
76   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
77   %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv, !dbg !30
78   %0 = trunc i64 %indvars.iv to i32, !dbg !30
79   store i32 %0, i32* %arrayidx, align 4, !dbg !30, !tbaa !18
80   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !25
81   %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !25
82   %exitcond = icmp eq i32 %lftr.wideiv, %Length, !dbg !25
83   br i1 %exitcond, label %for.end, label %for.body, !dbg !25, !llvm.loop !27
84
85 for.end:                                          ; preds = %for.body, %entry
86   ret void, !dbg !31
87 }
88
89 ; Function Attrs: nounwind optsize ssp uwtable
90 define void @_Z17test_array_boundsPiS_i(i32* nocapture %A, i32* nocapture readonly %B, i32 %Length) #0 {
91 entry:
92   %cmp9 = icmp sgt i32 %Length, 0, !dbg !32
93   br i1 %cmp9, label %for.body.preheader, label %for.end, !dbg !32, !llvm.loop !34
94
95 for.body.preheader:                               ; preds = %entry
96   br label %for.body, !dbg !35
97
98 for.body:                                         ; preds = %for.body.preheader, %for.body
99   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
100   %arrayidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv, !dbg !35
101   %0 = load i32* %arrayidx, align 4, !dbg !35, !tbaa !18
102   %idxprom1 = sext i32 %0 to i64, !dbg !35
103   %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %idxprom1, !dbg !35
104   %1 = load i32* %arrayidx2, align 4, !dbg !35, !tbaa !18
105   %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv, !dbg !35
106   store i32 %1, i32* %arrayidx4, align 4, !dbg !35, !tbaa !18
107   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !32
108   %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !32
109   %exitcond = icmp eq i32 %lftr.wideiv, %Length, !dbg !32
110   br i1 %exitcond, label %for.end.loopexit, label %for.body, !dbg !32, !llvm.loop !34
111
112 for.end.loopexit:                                 ; preds = %for.body
113   br label %for.end
114
115 for.end:                                          ; preds = %for.end.loopexit, %entry
116   ret void, !dbg !36
117 }
118
119 attributes #0 = { nounwind }
120
121 !llvm.dbg.cu = !{!0}
122 !llvm.module.flags = !{!9, !10}
123 !llvm.ident = !{!11}
124
125 !0 = !{!"0x11\004\00clang version 3.5.0\001\00\006\00\002", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [./source.cpp] [DW_LANG_C_plus_plus]
126 !1 = !{!"source.cpp", !"."}
127 !2 = !{}
128 !3 = !{!4, !7, !8}
129 !4 = !{!"0x2e\00test\00test\00\001\000\001\000\006\00256\001\001", !1, !5, !6, null, void (i32*, i32)* @_Z4testPii, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [test]
130 !5 = !{!"0x29", !1}          ; [ DW_TAG_file_type ] [./source.cpp]
131 !6 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
132 !7 = !{!"0x2e\00test_disabled\00test_disabled\00\0010\000\001\000\006\00256\001\0010", !1, !5, !6, null, void (i32*, i32)* @_Z13test_disabledPii, null, null, !2} ; [ DW_TAG_subprogram ] [line 10] [def] [test_disabled]
133 !8 = !{!"0x2e\00test_array_bounds\00test_array_bounds\00\0016\000\001\000\006\00256\001\0016", !1, !5, !6, null, void (i32*, i32*, i32)* @_Z17test_array_boundsPiS_i, null, null, !2} ; [ DW_TAG_subprogram ] [line 16] [def] [test_array_bounds]
134 !9 = !{i32 2, !"Dwarf Version", i32 2}
135 !10 = !{i32 2, !"Debug Info Version", i32 2}
136 !11 = !{!"clang version 3.5.0"}
137 !12 = !MDLocation(line: 3, column: 8, scope: !13)
138 !13 = !{!"0xb\003\003\000", !1, !4} ; [ DW_TAG_lexical_block ]
139 !14 = !{!14, !15, !15}
140 !15 = !{!"llvm.loop.vectorize.enable", i1 true}
141 !16 = !MDLocation(line: 4, column: 5, scope: !17)
142 !17 = !{!"0xb\003\0036\000", !1, !13} ; [ DW_TAG_lexical_block ]
143 !18 = !{!19, !19, i64 0}
144 !19 = !{!"int", !20, i64 0}
145 !20 = !{!"omnipotent char", !21, i64 0}
146 !21 = !{!"Simple C/C++ TBAA"}
147 !22 = !MDLocation(line: 5, column: 9, scope: !23)
148 !23 = !{!"0xb\005\009\000", !1, !17} ; [ DW_TAG_lexical_block ]
149 !24 = !MDLocation(line: 8, column: 1, scope: !4)
150 !25 = !MDLocation(line: 12, column: 8, scope: !26)
151 !26 = !{!"0xb\0012\003\000", !1, !7} ; [ DW_TAG_lexical_block ]
152 !27 = !{!27, !28, !29}
153 !28 = !{!"llvm.loop.interleave.count", i32 1}
154 !29 = !{!"llvm.loop.vectorize.width", i32 1}
155 !30 = !MDLocation(line: 13, column: 5, scope: !26)
156 !31 = !MDLocation(line: 14, column: 1, scope: !7)
157 !32 = !MDLocation(line: 18, column: 8, scope: !33)
158 !33 = !{!"0xb\0018\003\000", !1, !8} ; [ DW_TAG_lexical_block ]
159 !34 = !{!34, !15}
160 !35 = !MDLocation(line: 19, column: 5, scope: !33)
161 !36 = !MDLocation(line: 20, column: 1, scope: !8)