• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=thumbv7m -mattr=-no-branch-predictor | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BP
2; RUN: llc < %s -mtriple=thumbv7m -mcpu=cortex-m3 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOBP
3
4declare void @otherfn()
5
6; CHECK-LABEL: triangle1:
7; CHECK: itt ne
8; CHECK: movne
9; CHECK: strne
10define i32 @triangle1(i32 %n, i32* %p) {
11entry:
12  %tobool = icmp eq i32 %n, 0
13  br i1 %tobool, label %if.end, label %if.then
14
15if.then:
16  store i32 1, i32* %p, align 4
17  br label %if.end
18
19if.end:
20  tail call void @otherfn()
21  ret i32 0
22}
23
24; CHECK-LABEL: triangle2:
25; CHECK-BP: itttt ne
26; CHECK-BP: movne
27; CHECK-BP: strne
28; CHECK-BP: movne
29; CHECK-BP: strne
30; CHECK-NOBP: cbz
31; CHECK-NOBP: movs
32; CHECK-NOBP: str
33; CHECK-NOBP: movs
34; CHECK-NOBP: str
35define i32 @triangle2(i32 %n, i32* %p, i32* %q) {
36entry:
37  %tobool = icmp eq i32 %n, 0
38  br i1 %tobool, label %if.end, label %if.then
39
40if.then:
41  store i32 1, i32* %p, align 4
42  store i32 2, i32* %q, align 4
43  br label %if.end
44
45if.end:
46  tail call void @otherfn()
47  ret i32 0
48}
49
50; CHECK-LABEL: triangle3:
51; CHECK: cbz
52; CHECK: movs
53; CHECK: str
54; CHECK: movs
55; CHECK: str
56; CHECK: movs
57; CHECK: str
58define i32 @triangle3(i32 %n, i32* %p, i32* %q, i32* %r) {
59entry:
60  %tobool = icmp eq i32 %n, 0
61  br i1 %tobool, label %if.end, label %if.then
62
63if.then:
64  store i32 1, i32* %p, align 4
65  store i32 2, i32* %q, align 4
66  store i32 3, i32* %r, align 4
67  store i32 4, i32* %p, align 4
68  br label %if.end
69
70if.end:
71  tail call void @otherfn()
72  ret i32 0
73}
74
75; CHECK-LABEL: diamond1:
76; CHECK: itee eq
77; CHECK: ldreq
78; CHECK: strne
79define i32 @diamond1(i32 %n, i32* %p) {
80entry:
81  %tobool = icmp eq i32 %n, 0
82  br i1 %tobool, label %if.else, label %if.then
83
84if.then:
85  store i32 %n, i32* %p, align 4
86  br label %if.end
87
88if.else:
89  %0 = load i32, i32* %p, align 4
90  br label %if.end
91
92if.end:
93  %n.addr.0 = phi i32 [ %n, %if.then ], [ %0, %if.else ]
94  tail call void @otherfn()
95  ret i32 %n.addr.0
96}
97
98; CHECK-LABEL: diamond2:
99; CHECK-BP: cbz
100; CHECK-BP: str
101; CHECK-BP: str
102; CHECK-BP: b
103; CHECK-BP: str
104; CHECK-BP: add
105; CHECK-NOBP: ittee
106; CHECK-NOBP: streq
107; CHECK-NOBP: addeq
108; CHECK-NOBP: strne
109; CHECK-NOBP: strne
110define i32 @diamond2(i32 %n, i32* %p, i32* %q) {
111entry:
112  %tobool = icmp eq i32 %n, 0
113  br i1 %tobool, label %if.else, label %if.then
114
115if.then:
116  store i32 %n, i32* %p, align 4
117  %arrayidx = getelementptr inbounds i32, i32* %p, i32 2
118  store i32 %n, i32* %arrayidx, align 4
119  br label %if.end
120
121if.else:
122  store i32 %n, i32* %q, align 4
123  %0 = add i32 %n, 10
124  br label %if.end
125
126if.end:
127  %n.addr.0 = phi i32 [ %n, %if.then ], [ %0, %if.else ]
128  tail call void @otherfn()
129  ret i32 %n.addr.0
130}
131
132; CHECK-LABEL: diamond3:
133; CHECK: cbz
134; CHECK: movs
135; CHECK: str
136; CHECK: b
137; CHECK: ldr
138; CHECK: ldr
139; CHECK: adds
140define i32 @diamond3(i32 %n, i32* %p, i32* %q) {
141entry:
142  %tobool = icmp eq i32 %n, 0
143  br i1 %tobool, label %if.else, label %if.then
144
145if.then:
146  store i32 1, i32* %p, align 4
147  br label %if.end
148
149if.else:
150  %0 = load i32, i32* %p, align 4
151  %1 = load i32, i32* %q, align 4
152  %add = add nsw i32 %1, %0
153  br label %if.end
154
155if.end:
156  %n.addr.0 = phi i32 [ %n, %if.then ], [ %add, %if.else ]
157  tail call void @otherfn()
158  ret i32 %n.addr.0
159}
160