[Simplify] Remove unused instructions and accesses.
[polly-mirror.git] / test / ScopDetectionDiagnostics / ReportLoopBound-01.ll
blobe81bce5a127646955c12f775bc459465d708effd
1 ; RUN: opt %loadPolly \
2 ; RUN:     -pass-remarks-missed="polly-detect" -polly-detect-track-failures \
3 ; RUN:     -polly-allow-nonaffine-loops=false -polly-detect -analyze \
4 ; RUN:     < %s 2>&1| FileCheck %s --check-prefix=REJECTNONAFFINELOOPS
5 ; RUN: opt %loadPolly \
6 ; RUN:     -pass-remarks-missed="polly-detect" -polly-detect-track-failures \
7 ; RUN:     -polly-allow-nonaffine-loops=true -polly-detect -analyze \
8 ; RUN:     < %s 2>&1| FileCheck %s --check-prefix=ALLOWNONAFFINELOOPS
9 ; RUN: opt %loadPolly -pass-remarks-missed="polly-detect" \
10 ; RUN:     -polly-process-unprofitable=false \
11 ; RUN:     -polly-detect-track-failures -polly-allow-nonaffine-loops=true \
12 ; RUN:     -polly-allow-nonaffine -polly-detect -analyze < %s 2>&1 \
13 ; RUN:     | FileCheck %s --check-prefix=ALLOWNONAFFINEALL
15 ; void f(int A[], int n) {
16 ;   for (int i = 0; i < A[n+i]; i++)
17 ;     A[i] = 0;
18 ; }
20 ; If we reject non-affine loops the non-affine loop bound will be reported:
22 ; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:1:12: The following errors keep this region from being a Scop.
23 ; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:2:8: Failed to derive an affine function from the loop bounds.
24 ; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:3:5: Invalid Scop candidate ends here.
26 ; If we allow non-affine loops the non-affine access will be reported:
28 ; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:1:12: The following errors keep this region from being a Scop.
29 ; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:3:5: The array subscript of "A" is not affine
30 ; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:3:5: Invalid Scop candidate ends here.
32 ; If we allow non-affine loops and non-affine accesses the region will be reported as not profitable:
34 ; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:1:12: The following errors keep this region from being a Scop.
35 ; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:1:12: No profitable polyhedral optimization found
36 ; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:3:5: Invalid Scop candidate ends here.
38 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40 define void @f(i32* %A, i32 %n) !dbg !4 {
41 entry:
42   br label %entry.split
44 entry.split:                                      ; preds = %entry
45   tail call void @llvm.dbg.value(metadata i32* %A, i64 0, metadata !13, metadata !DIExpression()), !dbg !14
46   tail call void @llvm.dbg.value(metadata i32* %A, i64 0, metadata !13, metadata !DIExpression()), !dbg !14
47   tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !15, metadata !DIExpression()), !dbg !16
48   tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !18, metadata !DIExpression()), !dbg !20
49   %idxprom = sext i32 %n to i64, !dbg !21
50   %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom, !dbg !21
51   %0 = load i32, i32* %arrayidx, align 4, !dbg !21
52   %cmp3 = icmp sgt i32 %0, 0, !dbg !21
53   br i1 %cmp3, label %for.body.lr.ph, label %for.end, !dbg !21
55 for.body.lr.ph:                                   ; preds = %entry.split
56   br label %for.body, !dbg !22
58 for.body:                                         ; preds = %for.body.lr.ph, %for.body
59   %indvar = phi i64 [ 0, %for.body.lr.ph ], [ %indvar.next, %for.body ]
60   %arrayidx2 = getelementptr i32, i32* %A, i64 %indvar, !dbg !24
61   %1 = add i64 %indvar, 1, !dbg !24
62   %inc = trunc i64 %1 to i32, !dbg !21
63   store i32 0, i32* %arrayidx2, align 4, !dbg !24
64   tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !18, metadata !DIExpression()), !dbg !20
65   %arrayidx3 = getelementptr inbounds i32, i32* %arrayidx, i64 %indvar, !dbg !21
66   %2 = load i32, i32* %arrayidx3, align 4, !dbg !21
67   %cmp = icmp slt i32 %inc, %2, !dbg !21
68   %indvar.next = add i64 %indvar, 1, !dbg !21
69   br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !dbg !21
71 for.cond.for.end_crit_edge:                       ; preds = %for.body
72   br label %for.end, !dbg !25
74 for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry.split
75   ret void, !dbg !27
78 declare void @llvm.dbg.declare(metadata, metadata, metadata)
80 declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
82 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
83 attributes #1 = { nounwind readnone }
85 !llvm.dbg.cu = !{!0}
86 !llvm.module.flags = !{!10, !11}
87 !llvm.ident = !{!12}
89 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 ", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
90 !1 = !DIFile(filename: "ReportLoopBound-01.c", directory: "test/ScopDetectionDiagnostic/")
91 !2 = !{}
92 !4 = distinct !DISubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !2)
93 !5 = !DIFile(filename: "ReportLoopBound-01.c", directory: "test/ScopDetectionDiagnostic/")
94 !6 = !DISubroutineType(types: !7)
95 !7 = !{null, !8, !9}
96 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
97 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
98 !10 = !{i32 2, !"Dwarf Version", i32 4}
99 !11 = !{i32 2, !"Debug Info Version", i32 3}
100 !12 = !{!"clang version 3.6.0 "}
101 !13 = !DILocalVariable(name: "A", line: 1, arg: 1, scope: !4, file: !5, type: !8)
102 !14 = !DILocation(line: 1, column: 12, scope: !4)
103 !15 = !DILocalVariable(name: "n", line: 1, arg: 2, scope: !4, file: !5, type: !9)
104 !16 = !DILocation(line: 1, column: 21, scope: !4)
105 !17 = !{i32 0}
106 !18 = !DILocalVariable(name: "i", line: 2, scope: !19, file: !5, type: !9)
107 !19 = distinct !DILexicalBlock(line: 2, column: 3, file: !1, scope: !4)
108 !20 = !DILocation(line: 2, column: 12, scope: !19)
109 !21 = !DILocation(line: 2, column: 8, scope: !19)
110 !22 = !DILocation(line: 2, column: 8, scope: !23)
111 !23 = distinct !DILexicalBlock(line: 2, column: 8, file: !1, scope: !19)
112 !24 = !DILocation(line: 3, column: 5, scope: !19)
113 !25 = !DILocation(line: 2, column: 8, scope: !26)
114 !26 = distinct !DILexicalBlock(line: 2, column: 8, file: !1, scope: !19)
115 !27 = !DILocation(line: 4, column: 1, scope: !4)