blob: 1ceac9354820da174f86489a7c6bdb2f9622cfe4 [file] [log] [blame]
Chris Lattner6b88c762011-02-18 05:05:01 +00001; RUN: opt < %s -loop-unroll -S | FileCheck %s
Teresa Johnsonecd90132017-08-02 20:35:29 +00002; RUN: opt < %s -passes='require<opt-remark-emit>,unroll' -S | FileCheck %s
Chris Lattner6b88c762011-02-18 05:05:01 +00003
4
5; This should not unroll since the address of the loop header is taken.
6
Stephen Linc1c7a132013-07-14 01:42:54 +00007; CHECK-LABEL: @test1(
Chris Lattner6b88c762011-02-18 05:05:01 +00008; CHECK: store i8* blockaddress(@test1, %l1), i8** %P
9; CHECK: l1:
10; CHECK-NEXT: phi i32
11; rdar://8287027
12define i32 @test1(i8** %P) nounwind ssp {
13entry:
14 store i8* blockaddress(@test1, %l1), i8** %P
15 br label %l1
16
17l1: ; preds = %l1, %entry
18 %x.0 = phi i32 [ 0, %entry ], [ %inc, %l1 ]
19 %inc = add nsw i32 %x.0, 1
20 %exitcond = icmp eq i32 %inc, 3
21 br i1 %exitcond, label %l2, label %l1
22
23l2: ; preds = %l1
24 ret i32 0
25}
James Molloy4f6fb952012-12-20 16:04:27 +000026
27; This should not unroll since the call is 'noduplicate'.
28
Stephen Linc1c7a132013-07-14 01:42:54 +000029; CHECK-LABEL: @test2(
James Molloy4f6fb952012-12-20 16:04:27 +000030define i32 @test2(i8** %P) nounwind ssp {
31entry:
32 br label %l1
33
34l1: ; preds = %l1, %entry
35 %x.0 = phi i32 [ 0, %entry ], [ %inc, %l1 ]
36; CHECK: call void @f()
37; CHECK-NOT: call void @f()
38 call void @f() noduplicate
39 %inc = add nsw i32 %x.0, 1
40 %exitcond = icmp eq i32 %inc, 3
41 br i1 %exitcond, label %l2, label %l1
42
43l2: ; preds = %l1
44 ret i32 0
45; CHECK: }
46}
47
48declare void @f()