blob: c7ab6ef8218bf377bebda9fc6c11f8964d0ebaa2 [file] [log] [blame]
Chandler Carruth4162ece2011-10-21 08:01:56 +00001; RUN: llc -march=x86 -enable-block-placement < %s | FileCheck %s
2
3declare void @error(i32 %i, i32 %a, i32 %b)
4
5define i32 @test1(i32 %i, i32* %a, i32 %b) {
6; Test a chain of ifs, where the block guarded by the if is error handling code
7; that is not expected to run.
8; CHECK: test1:
9; CHECK: %entry
10; CHECK: %else1
11; CHECK: %else2
12; CHECK: %else3
13; CHECK: %else4
14; CHECK: %exit
15; CHECK: %then1
16; CHECK: %then2
17; CHECK: %then3
18; CHECK: %then4
19; CHECK: %then5
20
21entry:
22 %gep1 = getelementptr i32* %a, i32 1
23 %val1 = load i32* %gep1
24 %cond1 = icmp ugt i32 %val1, 1
25 br i1 %cond1, label %then1, label %else1, !prof !0
26
27then1:
28 call void @error(i32 %i, i32 1, i32 %b)
29 br label %else1
30
31else1:
32 %gep2 = getelementptr i32* %a, i32 2
33 %val2 = load i32* %gep2
34 %cond2 = icmp ugt i32 %val2, 2
35 br i1 %cond2, label %then2, label %else2, !prof !0
36
37then2:
38 call void @error(i32 %i, i32 1, i32 %b)
39 br label %else2
40
41else2:
42 %gep3 = getelementptr i32* %a, i32 3
43 %val3 = load i32* %gep3
44 %cond3 = icmp ugt i32 %val3, 3
45 br i1 %cond3, label %then3, label %else3, !prof !0
46
47then3:
48 call void @error(i32 %i, i32 1, i32 %b)
49 br label %else3
50
51else3:
52 %gep4 = getelementptr i32* %a, i32 4
53 %val4 = load i32* %gep4
54 %cond4 = icmp ugt i32 %val4, 4
55 br i1 %cond4, label %then4, label %else4, !prof !0
56
57then4:
58 call void @error(i32 %i, i32 1, i32 %b)
59 br label %else4
60
61else4:
62 %gep5 = getelementptr i32* %a, i32 3
63 %val5 = load i32* %gep5
64 %cond5 = icmp ugt i32 %val5, 3
65 br i1 %cond5, label %then5, label %exit, !prof !0
66
67then5:
68 call void @error(i32 %i, i32 1, i32 %b)
69 br label %exit
70
71exit:
72 ret i32 %b
73}
74
75!0 = metadata !{metadata !"branch_weights", i32 4, i32 64}