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