1; RUN: opt < %s -loop-vectorize -mtriple=x86_64-unknown-linux -S -pass-remarks='loop-vectorize' -pass-remarks-missed='loop-vectorize' -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck %s
2
3; CHECK: remark: no_fpmath.c:6:11: loop not vectorized: cannot prove it is safe to reorder floating-point operations
4; CHECK: remark: no_fpmath.c:6:14: loop not vectorized:
5; CHECK: remark: no_fpmath.c:17:14: vectorized loop (vectorization width: 2, interleaved count: 2)
6
7target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-apple-macosx10.10.0"
9
10; Function Attrs: nounwind readonly ssp uwtable
11define double @cond_sum(i32* nocapture readonly %v, i32 %n) #0 !dbg !4 {
12entry:
13  %cmp.7 = icmp sgt i32 %n, 0, !dbg !3
14  br i1 %cmp.7, label %for.body.preheader, label %for.cond.cleanup, !dbg !8
15
16for.body.preheader:                               ; preds = %entry
17  br label %for.body, !dbg !9
18
19for.cond.cleanup.loopexit:                        ; preds = %for.body
20  %add.lcssa = phi double [ %add, %for.body ]
21  br label %for.cond.cleanup, !dbg !10
22
23for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
24  %a.0.lcssa = phi double [ 0.000000e+00, %entry ], [ %add.lcssa, %for.cond.cleanup.loopexit ]
25  ret double %a.0.lcssa, !dbg !10
26
27for.body:                                         ; preds = %for.body.preheader, %for.body
28  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
29  %a.08 = phi double [ %add, %for.body ], [ 0.000000e+00, %for.body.preheader ]
30  %arrayidx = getelementptr inbounds i32, i32* %v, i64 %indvars.iv, !dbg !9
31  %0 = load i32, i32* %arrayidx, align 4, !dbg !9, !tbaa !11
32  %cmp1 = icmp eq i32 %0, 0, !dbg !15
33  %cond = select i1 %cmp1, double 3.400000e+00, double 1.150000e+00, !dbg !9
34  %add = fadd double %a.08, %cond, !dbg !16
35  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !8
36  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !8
37  %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !8
38  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !8, !llvm.loop !17
39}
40
41; Function Attrs: nounwind readonly ssp uwtable
42define double @cond_sum_loop_hint(i32* nocapture readonly %v, i32 %n) #0 !dbg !20 {
43entry:
44  %cmp.7 = icmp sgt i32 %n, 0, !dbg !19
45  br i1 %cmp.7, label %for.body.preheader, label %for.cond.cleanup, !dbg !21
46
47for.body.preheader:                               ; preds = %entry
48  br label %for.body, !dbg !22
49
50for.cond.cleanup.loopexit:                        ; preds = %for.body
51  %add.lcssa = phi double [ %add, %for.body ]
52  br label %for.cond.cleanup, !dbg !23
53
54for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
55  %a.0.lcssa = phi double [ 0.000000e+00, %entry ], [ %add.lcssa, %for.cond.cleanup.loopexit ]
56  ret double %a.0.lcssa, !dbg !23
57
58for.body:                                         ; preds = %for.body.preheader, %for.body
59  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
60  %a.08 = phi double [ %add, %for.body ], [ 0.000000e+00, %for.body.preheader ]
61  %arrayidx = getelementptr inbounds i32, i32* %v, i64 %indvars.iv, !dbg !22
62  %0 = load i32, i32* %arrayidx, align 4, !dbg !22, !tbaa !11
63  %cmp1 = icmp eq i32 %0, 0, !dbg !24
64  %cond = select i1 %cmp1, double 3.400000e+00, double 1.150000e+00, !dbg !22
65  %add = fadd double %a.08, %cond, !dbg !25
66  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !21
67  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !21
68  %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !21
69  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !21, !llvm.loop !26
70}
71
72attributes #0 = { nounwind }
73
74!llvm.dbg.cu = !{!28}
75!llvm.module.flags = !{!0, !1}
76!llvm.ident = !{!2}
77
78!0 = !{i32 2, !"Debug Info Version", i32 3}
79!1 = !{i32 1, !"PIC Level", i32 2}
80!2 = !{!"clang version 3.7.0"}
81!3 = !DILocation(line: 5, column: 20, scope: !4)
82!4 = distinct !DISubprogram(name: "cond_sum", scope: !5, file: !5, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !28, variables: !7)
83!5 = !DIFile(filename: "no_fpmath.c", directory: "")
84!6 = !DISubroutineType(types: !7)
85!7 = !{}
86!8 = !DILocation(line: 5, column: 3, scope: !4)
87!9 = !DILocation(line: 6, column: 14, scope: !4)
88!10 = !DILocation(line: 9, column: 3, scope: !4)
89!11 = !{!12, !12, i64 0}
90!12 = !{!"int", !13, i64 0}
91!13 = !{!"omnipotent char", !14, i64 0}
92!14 = !{!"Simple C/C++ TBAA"}
93!15 = !DILocation(line: 6, column: 19, scope: !4)
94!16 = !DILocation(line: 6, column: 11, scope: !4)
95!17 = distinct !{!17, !18}
96!18 = !{!"llvm.loop.unroll.disable"}
97!19 = !DILocation(line: 16, column: 20, scope: !20)
98!20 = distinct !DISubprogram(name: "cond_sum_loop_hint", scope: !5, file: !5, line: 12, type: !6, isLocal: false, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: true, unit: !28, variables: !7)
99!21 = !DILocation(line: 16, column: 3, scope: !20)
100!22 = !DILocation(line: 17, column: 14, scope: !20)
101!23 = !DILocation(line: 20, column: 3, scope: !20)
102!24 = !DILocation(line: 17, column: 19, scope: !20)
103!25 = !DILocation(line: 17, column: 11, scope: !20)
104!26 = distinct !{!26, !27, !18}
105!27 = !{!"llvm.loop.vectorize.enable", i1 true}
106!28 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
107                             file: !5,
108                             isOptimized: true, flags: "-O2",
109                             splitDebugFilename: "abc.debug", emissionKind: 2)
110