xref: /llvm-project/llvm/test/CodeGen/X86/code_placement_ignore_succ_in_inner_loop.ll (revision f9f81289e6864ca3f09df16bad0ffc3ca58c3162)
1; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux < %s | FileCheck %s
2
3define void @foo() {
4; After moving the latch to the top of loop, there is no fall through from the
5; latch to outer loop.
6;
7; CHECK-LABEL: foo:
8; CHECK: callq b
9; CHECK: callq c
10
11entry:
12  %call = call zeroext i1 @a()
13  br i1 %call, label %if.then, label %if.else, !prof !1
14
15if.then:
16  %call1 = call zeroext i1 @a()
17  br i1 %call1, label %while.body, label %if.end.1, !prof !1
18
19while.body:
20  %call2 = call zeroext i1 @a()
21  br i1 %call2, label %if.then.1, label %while.cond
22
23if.then.1:
24  call void @d()
25  br label %while.cond
26
27while.cond:
28  %call3 = call zeroext i1 @a()
29  br i1 %call3, label %while.body, label %if.end
30
31if.end.1:
32  call void @d()
33  br label %if.end
34
35if.else:
36  call void @b()
37  br label %if.end
38
39if.end:
40  call void @c()
41  ret void
42}
43
44define void @bar() {
45; Test that when determining the edge probability from a node in a loop to a
46; node in its peer loop, the weights on edges in the first loop should be
47; ignored.
48;
49; CHECK-LABEL: bar:
50; CHECK: callq c
51; CHECK: callq b
52
53entry:
54  %call = call zeroext i1 @a()
55  br i1 %call, label %if.then, label %if.else, !prof !1
56
57if.then:
58  %call1 = call zeroext i1 @a()
59  br i1 %call1, label %if.then, label %while.body, !prof !2
60
61while.body:
62  %call2 = call zeroext i1 @a()
63  br i1 %call2, label %while.body, label %if.end, !prof !2
64
65if.else:
66  call void @b()
67  br label %if.end
68
69if.end:
70  call void @c()
71  ret void
72}
73
74define void @par() {
75; Test that when determining the edge probability from a node in a loop to a
76; node in its outer loop, the weights on edges in the outer loop should be
77; ignored if we are building the chain for the inner loop.
78;
79; CHECK-LABEL: par:
80; CHECK: callq c
81; CHECK: callq d
82; CHECK: callq b
83
84entry:
85  br label %if.cond
86
87if.cond:
88  %call = call zeroext i1 @a()
89  br i1 %call, label %if.then, label %if.else, !prof !3
90
91if.then:
92  call void @b()
93  br label %if.end
94
95if.else:
96  call void @c()
97  %call1 = call zeroext i1 @a()
98  br i1 %call1, label %if.end, label %exit, !prof !4
99
100if.end:
101  call void @d()
102  %call2 = call zeroext i1 @a()
103  br i1 %call2, label %if.cond, label %if.end.2, !prof !2
104
105if.end.2:
106  call void @e()
107  br label %if.cond
108
109exit:
110  ret void
111}
112
113declare zeroext i1 @a()
114declare void @b()
115declare void @c()
116declare void @d()
117declare void @e()
118
119!1 = !{!"branch_weights", i32 10, i32 1}
120!2 = !{!"branch_weights", i32 100, i32 1}
121!3 = !{!"branch_weights", i32 1, i32 100}
122!4 = !{!"branch_weights", i32 1, i32 1}
123