1*cee313d2SEric Christopher; RUN: opt < %s -loop-extract -S | FileCheck %s
2*cee313d2SEric Christopher
3*cee313d2SEric Christopher@label = common local_unnamed_addr global i8* null
4*cee313d2SEric Christopher
5*cee313d2SEric Christopher; CHECK: define
6*cee313d2SEric Christopher; no outlined function
7*cee313d2SEric Christopher; CHECK-NOT: define
8*cee313d2SEric Christopherdefine i32 @sterix(i32 %n) {
9*cee313d2SEric Christopherentry:
10*cee313d2SEric Christopher  %tobool = icmp ne i32 %n, 0
11*cee313d2SEric Christopher  ; this blockaddress references a basic block that goes in the extracted loop
12*cee313d2SEric Christopher  %cond = select i1 %tobool, i8* blockaddress(@sterix, %for.cond), i8* blockaddress(@sterix, %exit)
13*cee313d2SEric Christopher  store i8* %cond, i8** @label
14*cee313d2SEric Christopher  %cmp5 = icmp sgt i32 %n, 0
15*cee313d2SEric Christopher  br i1 %cmp5, label %for.body, label %exit
16*cee313d2SEric Christopher
17*cee313d2SEric Christopherfor.cond:
18*cee313d2SEric Christopher  %mul = shl nsw i32 %s.06, 1
19*cee313d2SEric Christopher  %exitcond = icmp eq i32 %inc, %n
20*cee313d2SEric Christopher  br i1 %exitcond, label %exit.loopexit, label %for.body
21*cee313d2SEric Christopher
22*cee313d2SEric Christopherfor.body:
23*cee313d2SEric Christopher  %i.07 = phi i32 [ %inc, %for.cond ], [ 0, %entry ]
24*cee313d2SEric Christopher  %s.06 = phi i32 [ %mul, %for.cond ], [ 1, %entry ]
25*cee313d2SEric Christopher  %inc = add nuw nsw i32 %i.07, 1
26*cee313d2SEric Christopher  br label %for.cond
27*cee313d2SEric Christopher
28*cee313d2SEric Christopherexit.loopexit:
29*cee313d2SEric Christopher  %phitmp = icmp ne i32 %s.06, 2
30*cee313d2SEric Christopher  %phitmp8 = zext i1 %phitmp to i32
31*cee313d2SEric Christopher  br label %exit
32*cee313d2SEric Christopher
33*cee313d2SEric Christopherexit:
34*cee313d2SEric Christopher  %s.1 = phi i32 [ 1, %entry ], [ %phitmp8, %exit.loopexit ]
35*cee313d2SEric Christopher  ret i32 %s.1
36*cee313d2SEric Christopher}
37