• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -loop-simplifycfg < %s | FileCheck %s
2; RUN: opt -S -passes='require<domtree>,loop(simplify-cfg)' < %s | FileCheck %s
3
4; CHECK-LABEL: foo
5; CHECK:      entry:
6; CHECK-NEXT:   br label %[[LOOP:[a-z]+]]
7; CHECK:      [[LOOP]]:
8; CHECK-NEXT:   phi
9; CHECK-NOT:    br label
10; CHECK:        br i1
11define i32 @foo(i32* %P, i64* %Q) {
12entry:
13  br label %outer
14
15outer:                                            ; preds = %outer.latch2, %entry
16  %y.2 = phi i32 [ 0, %entry ], [ %y.inc2, %outer.latch2 ]
17  br label %inner
18
19inner:                                            ; preds = %outer
20  store i32 0, i32* %P
21  store i32 1, i32* %P
22  store i32 2, i32* %P
23  %y.inc2 = add nsw i32 %y.2, 1
24  %exitcond.outer = icmp eq i32 %y.inc2, 3
25  store i32 %y.2, i32* %P
26  br i1 %exitcond.outer, label %exit, label %outer.latch2
27
28outer.latch2:                                     ; preds = %inner
29  %t = sext i32 %y.inc2 to i64
30  store i64 %t, i64* %Q
31  br label %outer
32
33exit:                                             ; preds = %inner
34  ret i32 0
35}
36