blob: 5613fdb6c6aad4553b0d17bffa7765d49d54bbf5 [file] [log] [blame]
Karl Schimpfc836acb2014-09-05 08:32:47 -07001; Tests if we handle a branch instructions.
2
Karl Schimpf2a5324a2014-09-25 09:37:49 -07003; RUN: %p2i -i %s --insts | FileCheck %s
Jim Stichnoth0d4fc922015-12-13 21:36:33 -08004; RUN: %p2i -i %s --args -notranslate -timing | \
Karl Schimpf6fcbddd2014-11-06 09:49:24 -08005; RUN: FileCheck --check-prefix=NOIR %s
Karl Schimpfc836acb2014-09-05 08:32:47 -07006
Karl Schimpf57d31ac2015-10-07 09:53:12 -07007define internal void @SimpleBranch() {
Karl Schimpfc132b762014-09-11 09:43:47 -07008entry:
Karl Schimpfc836acb2014-09-05 08:32:47 -07009 br label %b3
10b1:
11 br label %b2
12b2:
13 ret void
14b3:
15 br label %b1
16}
17
Karl Schimpf57d31ac2015-10-07 09:53:12 -070018; CHECK: define internal void @SimpleBranch() {
Karl Schimpfc132b762014-09-11 09:43:47 -070019; CHECK-NEXT: entry:
20; CHECK-NEXT: br label %b3
21; CHECK-NEXT: b1:
22; CHECK-NEXT: br label %b2
23; CHECK-NEXT: b2:
Karl Schimpfc836acb2014-09-05 08:32:47 -070024; CHECK-NEXT: ret void
Karl Schimpfc132b762014-09-11 09:43:47 -070025; CHECK-NEXT: b3:
26; CHECK-NEXT: br label %b1
Karl Schimpfc836acb2014-09-05 08:32:47 -070027; CHECK-NEXT: }
28
Karl Schimpf57d31ac2015-10-07 09:53:12 -070029define internal void @CondBranch(i32 %p) {
Karl Schimpfc132b762014-09-11 09:43:47 -070030entry:
Karl Schimpfc836acb2014-09-05 08:32:47 -070031 %test = trunc i32 %p to i1
32 br i1 %test, label %b1, label %b2
33b1:
34 ret void
35b2:
36 br i1 %test, label %b2, label %b1
37}
38
Karl Schimpf57d31ac2015-10-07 09:53:12 -070039; CHECK-NEXT: define internal void @CondBranch(i32 %p) {
Karl Schimpfc132b762014-09-11 09:43:47 -070040; CHECK-NEXT: entry:
41; CHECK-NEXT: %test = trunc i32 %p to i1
42; CHECK-NEXT: br i1 %test, label %b1, label %b2
43; CHECK-NEXT: b1:
Karl Schimpfc836acb2014-09-05 08:32:47 -070044; CHECK-NEXT: ret void
Karl Schimpfc132b762014-09-11 09:43:47 -070045; CHECK-NEXT: b2:
46; CHECK-NEXT: br i1 %test, label %b2, label %b1
Karl Schimpfc836acb2014-09-05 08:32:47 -070047; CHECK-NEXT: }
Karl Schimpf6fcbddd2014-11-06 09:49:24 -080048
49; NOIR: Total across all functions