2 ; RUN: opt -passes=loop-distribute -enable-loop-distribute \
3 ; RUN: -debug-only=loop-distribute -disable-output 2>&1 %s | FileCheck %s
5 define void @f(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, i64 %stride) {
6 ; CHECK-LABEL: LDist: Checking a loop in 'f' from f.c:5:2
10 for.body: ; preds = %for.body, %entry
11 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
12 %gep.a = getelementptr inbounds i32, ptr %a, i64 %ind
13 %load.a = load i32, ptr %gep.a, align 4
14 %gep.b = getelementptr inbounds i32, ptr %b, i64 %ind
15 %load.b = load i32, ptr %gep.b, align 4
16 %mul.a = mul i32 %load.b, %load.a
17 %add = add nuw nsw i64 %ind, 1
18 %gep.a.plus4 = getelementptr inbounds i32, ptr %a, i64 %add
19 store i32 %mul.a, ptr %gep.a.plus4, align 4
20 %gep.d = getelementptr inbounds i32, ptr %d, i64 %ind
21 %loadD = load i32, ptr %gep.d, align 4
22 %mul = mul i64 %ind, %stride
23 %gep.strided.a = getelementptr inbounds i32, ptr %a, i64 %mul
24 %load.strided.a = load i32, ptr %gep.strided.a, align 4
25 %mul.c = mul i32 %loadD, %load.strided.a
26 %gep.c = getelementptr inbounds i32, ptr %c, i64 %ind
27 store i32 %mul.c, ptr %gep.c, align 4
28 %exitcond = icmp eq i64 %add, 20
29 br i1 %exitcond, label %exit, label %for.body, !dbg !2
31 exit: ; preds = %for.body
35 !llvm.module.flags = !{!5, !6, !7}
37 !0 = !DIFile(filename: "f.c", directory: "/")
38 !1 = distinct !DISubprogram(name: "f", scope: !0, file: !0, unit: !4)
39 !2 = !DILocation(line: 5, column: 2, scope: !1)
40 !4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !0, producer: "clang")
41 !5 = !{i32 1, !"Debug Info Version", i32 3}
42 !6 = !{i32 2, !"Dwarf Version", i32 2}
43 !7 = !{i32 1, !"PIC Level", i32 2}