1; RUN: opt -mcpu=cyclone -mtriple=arm64-apple-ios -loop-data-prefetch \
2; RUN:     -pass-remarks=loop-data-prefetch -S -max-prefetch-iters-ahead=100 \
3; RUN:     < %s 2>&1 | FileCheck %s
4; RUN: opt -mcpu=cyclone -mtriple=arm64-apple-ios -passes=loop-data-prefetch \
5; RUN:     -pass-remarks=loop-data-prefetch -S -max-prefetch-iters-ahead=100 \
6; RUN:     < %s 2>&1 | FileCheck %s
7
8; ModuleID = '/tmp/s.c'
9source_filename = "/tmp/s.c"
10target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
11target triple = "arm64-apple-ios5.0.0"
12
13;   1	struct MyStruct {
14;   2	  int field;
15;   3	  char kk[2044];
16;   4	} *my_struct;
17;   5
18;   6	int f(struct MyStruct *p, int N) {
19;   7	  int total = 0;
20;   8	  for (int i = 0; i < N; i++) {
21;   9	    total += my_struct[i].field;
22;  10	  }
23;  11	  return total;
24;  12	}
25
26; CHECK: remark: /tmp/s.c:9:27: prefetched memory access
27
28%struct.MyStruct = type { i32, [2044 x i8] }
29
30@my_struct = common global %struct.MyStruct* null, align 8
31
32define i32 @f(%struct.MyStruct* nocapture readnone %p, i32 %N) !dbg !6 {
33entry:
34  %cmp6 = icmp sgt i32 %N, 0, !dbg !8
35  br i1 %cmp6, label %for.body.lr.ph, label %for.cond.cleanup, !dbg !9
36
37for.body.lr.ph:                                   ; preds = %entry
38  %0 = load %struct.MyStruct*, %struct.MyStruct** @my_struct, align 8, !dbg !10, !tbaa !11
39  br label %for.body, !dbg !9
40
41for.cond.cleanup:                                 ; preds = %for.body, %entry
42  %total.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
43  ret i32 %total.0.lcssa, !dbg !15
44
45for.body:                                         ; preds = %for.body, %for.body.lr.ph
46  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
47  %total.07 = phi i32 [ 0, %for.body.lr.ph ], [ %add, %for.body ]
48  %field = getelementptr inbounds %struct.MyStruct, %struct.MyStruct* %0, i64 %indvars.iv, i32 0, !dbg !16
49  %1 = load i32, i32* %field, align 4, !dbg !16, !tbaa !17
50  %add = add nsw i32 %1, %total.07, !dbg !20
51  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !9
52  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9
53  %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !9
54  br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !9
55}
56
57!llvm.dbg.cu = !{!0}
58!llvm.module.flags = !{!3, !4}
59!llvm.ident = !{!5}
60
61!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
62!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
63!2 = !{}
64!3 = !{i32 2, !"Debug Info Version", i32 3}
65!4 = !{i32 1, !"PIC Level", i32 2}
66!5 = !{!"clang version 3.9.0"}
67!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 6, type: !7, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
68!7 = !DISubroutineType(types: !2)
69!8 = !DILocation(line: 8, column: 21, scope: !6)
70!9 = !DILocation(line: 8, column: 3, scope: !6)
71!10 = !DILocation(line: 9, column: 14, scope: !6)
72!11 = !{!12, !12, i64 0}
73!12 = !{!"any pointer", !13, i64 0}
74!13 = !{!"omnipotent char", !14, i64 0}
75!14 = !{!"Simple C/C++ TBAA"}
76!15 = !DILocation(line: 11, column: 3, scope: !6)
77!16 = !DILocation(line: 9, column: 27, scope: !6)
78!17 = !{!18, !19, i64 0}
79!18 = !{!"MyStruct", !19, i64 0, !13, i64 4}
80!19 = !{!"int", !13, i64 0}
81!20 = !DILocation(line: 9, column: 11, scope: !6)
82