1; RUN: opt < %s -loop-vectorize -pass-remarks-analysis='loop-vectorize' -mtriple=x86_64-unknown-linux -S 2>&1 | FileCheck %s
2
3; Verify analysis remarks are generated when interleaving is not beneficial.
4; CHECK: remark: vectorization-remarks-profitable.c:4:14: the cost-model indicates that vectorization is not beneficial
5; CHECK: remark: vectorization-remarks-profitable.c:4:14: the cost-model indicates that interleaving is not beneficial and is explicitly disabled or interleave count is set to 1
6; CHECK: remark: vectorization-remarks-profitable.c:11:14: the cost-model indicates that vectorization is not beneficial
7; CHECK: remark: vectorization-remarks-profitable.c:11:14: the cost-model indicates that interleaving is not beneficial
8
9; First loop.
10;  #pragma clang loop interleave(disable) unroll(disable)
11;  for(int i = 0; i < n; i++) {
12;    out[i] = in[i];
13;  }
14
15; Second loop.
16;  #pragma clang loop unroll(disable)
17;  for(int i = 0; i < n; i++) {
18;    out[i] = in[i];
19;  }
20
21target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
22target triple = "x86_64-apple-macosx10.10.0"
23
24; Function Attrs: nounwind ssp uwtable
25define void @do_not_interleave(float* nocapture %out, float* nocapture readonly %in, i32 %n) #0 {
26entry:
27  %cmp.7 = icmp sgt i32 %n, 0, !dbg !3
28  br i1 %cmp.7, label %for.body.preheader, label %for.cond.cleanup, !dbg !8
29
30for.body.preheader:                               ; preds = %entry
31  br label %for.body, !dbg !9
32
33for.cond.cleanup.loopexit:                        ; preds = %for.body
34  br label %for.cond.cleanup, !dbg !10
35
36for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
37  ret void, !dbg !10
38
39for.body:                                         ; preds = %for.body.preheader, %for.body
40  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
41  %arrayidx = getelementptr inbounds float, float* %in, i64 %indvars.iv, !dbg !9
42  %0 = bitcast float* %arrayidx to i32*, !dbg !9
43  %1 = load i32, i32* %0, align 4, !dbg !9, !tbaa !11
44  %arrayidx2 = getelementptr inbounds float, float* %out, i64 %indvars.iv, !dbg !15
45  %2 = bitcast float* %arrayidx2 to i32*, !dbg !16
46  store i32 %1, i32* %2, align 4, !dbg !16, !tbaa !11
47  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !8
48  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !8
49  %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !8
50  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !8, !llvm.loop !17
51}
52
53; Function Attrs: nounwind ssp uwtable
54define void @interleave_not_profitable(float* nocapture %out, float* nocapture readonly %in, i32 %n) #0 {
55entry:
56  %cmp.7 = icmp sgt i32 %n, 0, !dbg !20
57  br i1 %cmp.7, label %for.body.preheader, label %for.cond.cleanup, !dbg !22
58
59for.body.preheader:                               ; preds = %entry
60  br label %for.body, !dbg !23
61
62for.cond.cleanup.loopexit:                        ; preds = %for.body
63  br label %for.cond.cleanup, !dbg !24
64
65for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
66  ret void, !dbg !24
67
68for.body:                                         ; preds = %for.body.preheader, %for.body
69  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
70  %arrayidx = getelementptr inbounds float, float* %in, i64 %indvars.iv, !dbg !23
71  %0 = bitcast float* %arrayidx to i32*, !dbg !23
72  %1 = load i32, i32* %0, align 4, !dbg !23, !tbaa !11
73  %arrayidx2 = getelementptr inbounds float, float* %out, i64 %indvars.iv, !dbg !25
74  %2 = bitcast float* %arrayidx2 to i32*, !dbg !26
75  store i32 %1, i32* %2, align 4, !dbg !26, !tbaa !11
76  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !22
77  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !22
78  %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !22
79  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !22, !llvm.loop !27
80}
81
82attributes #0 = { nounwind }
83
84!llvm.module.flags = !{!0, !1}
85!llvm.ident = !{!2}
86
87!0 = !{i32 2, !"Debug Info Version", i32 3}
88!1 = !{i32 1, !"PIC Level", i32 2}
89!2 = !{!"clang version 3.7.0"}
90!3 = !DILocation(line: 3, column: 20, scope: !4)
91!4 = distinct !DISubprogram(name: "do_not_interleave", scope: !5, file: !5, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, function: void (float*, float*, i32)* @do_not_interleave, variables: !7)
92!5 = !DIFile(filename: "vectorization-remarks-profitable.c", directory: "")
93!6 = !DISubroutineType(types: !7)
94!7 = !{}
95!8 = !DILocation(line: 3, column: 3, scope: !4)
96!9 = !DILocation(line: 4, column: 14, scope: !4)
97!10 = !DILocation(line: 6, column: 1, scope: !4)
98!11 = !{!12, !12, i64 0}
99!12 = !{!"float", !13, i64 0}
100!13 = !{!"omnipotent char", !14, i64 0}
101!14 = !{!"Simple C/C++ TBAA"}
102!15 = !DILocation(line: 4, column: 5, scope: !4)
103!16 = !DILocation(line: 4, column: 12, scope: !4)
104!17 = distinct !{!17, !18, !19}
105!18 = !{!"llvm.loop.interleave.count", i32 1}
106!19 = !{!"llvm.loop.unroll.disable"}
107!20 = !DILocation(line: 10, column: 20, scope: !21)
108!21 = distinct !DISubprogram(name: "interleave_not_profitable", scope: !5, file: !5, line: 8, type: !6, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, function: void (float*, float*, i32)* @interleave_not_profitable, variables: !7)
109!22 = !DILocation(line: 10, column: 3, scope: !21)
110!23 = !DILocation(line: 11, column: 14, scope: !21)
111!24 = !DILocation(line: 13, column: 1, scope: !21)
112!25 = !DILocation(line: 11, column: 5, scope: !21)
113!26 = !DILocation(line: 11, column: 12, scope: !21)
114!27 = distinct !{!27, !19}
115