[PGO] MST based PGO instrumentation infrastructure
[oota-llvm.git] / test / Transforms / PGOProfile / loop3_gen.ll
1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
4
5 ; CHECK: @__llvm_profile_name__Z15test_nested_foriii = private constant [22 x i8] c"_Z15test_nested_foriii"
6
7 define i32 @_Z15test_nested_foriii(i32 %r, i32 %s, i32 %t) {
8 entry:
9 ; CHECK: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__llvm_profile_name__Z15test_nested_foriii, i32 0, i32 0), i64 75296580464, i32 4, i32 3)
10   br label %for.cond
11
12 for.cond:
13   %i.0 = phi i32 [ 0, %entry ], [ %inc12, %for.inc11 ]
14   %nested_for_sum.0 = phi i32 [ 1, %entry ], [ %nested_for_sum.1, %for.inc11 ]
15   %cmp = icmp slt i32 %i.0, %r
16   br i1 %cmp, label %for.body, label %for.end13
17
18 for.body:
19   br label %for.cond1
20
21 for.cond1:
22   %j.0 = phi i32 [ 0, %for.body ], [ %inc9, %for.inc8 ]
23   %nested_for_sum.1 = phi i32 [ %nested_for_sum.0, %for.body ], [ %nested_for_sum.2, %for.inc8 ]
24   %cmp2 = icmp slt i32 %j.0, %s
25   br i1 %cmp2, label %for.body3, label %for.end10
26
27 for.body3:
28   br label %for.cond4
29
30 for.cond4:
31   %k.0 = phi i32 [ 0, %for.body3 ], [ %inc7, %for.inc ]
32   %nested_for_sum.2 = phi i32 [ %nested_for_sum.1, %for.body3 ], [ %inc, %for.inc ]
33   %cmp5 = icmp slt i32 %k.0, %t
34   br i1 %cmp5, label %for.body6, label %for.end
35
36 for.body6:
37   %inc = add nsw i32 %nested_for_sum.2, 1
38   br label %for.inc
39
40 for.inc:
41 ; CHECK: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__llvm_profile_name__Z15test_nested_foriii, i32 0, i32 0), i64 75296580464, i32 4, i32 0)
42   %inc7 = add nsw i32 %k.0, 1
43   br label %for.cond4
44
45 for.end:
46   br label %for.inc8
47
48 for.inc8:
49 ; CHECK: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__llvm_profile_name__Z15test_nested_foriii, i32 0, i32 0), i64 75296580464, i32 4, i32 1)
50   %inc9 = add nsw i32 %j.0, 1
51   br label %for.cond1
52
53 for.end10:
54 ; CHECK: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__llvm_profile_name__Z15test_nested_foriii, i32 0, i32 0), i64 75296580464, i32 4, i32 2)
55   br label %for.inc11
56
57 for.inc11:
58   %inc12 = add nsw i32 %i.0, 1
59   br label %for.cond
60
61 for.end13:
62   ret i32 %nested_for_sum.0
63 }