1 ; RUN: opt -S < %s -instcombine -inline -jump-threading -loop-unroll -unroll-count=4 | FileCheck %s
3 ; This is a test case that required a number of setup passes because
4 ; it depends on block order.
6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
7 target triple = "x86_64-apple-macosx10.6.8"
9 declare i1 @check() nounwind
10 declare i32 @getval() nounwind
12 ; Check that the loop exit merges values from all the iterations. This
13 ; could be a tad fragile, but it's a good test.
17 ; CHECK: %retval.0 = phi i32 [ %tmp7.i, %land.lhs.true ], [ 0, %do.cond ], [ %tmp7.i.1, %land.lhs.true.1 ], [ 0, %do.cond.1 ], [ %tmp7.i.2, %land.lhs.true.2 ], [ 0, %do.cond.2 ], [ %tmp7.i.3, %land.lhs.true.3 ], [ 0, %do.cond.3 ]
20 define i32 @foo() uwtable ssp align 2 {
22 br i1 undef, label %return, label %if.end
24 if.end: ; preds = %entry
25 %call2 = call i32 @getval()
28 do.body: ; preds = %do.cond, %if.end
29 %call6 = call i32 @bar()
30 %cmp = icmp ne i32 %call6, 0
31 br i1 %cmp, label %land.lhs.true, label %do.cond
33 land.lhs.true: ; preds = %do.body
34 %call10 = call i32 @getval()
35 %cmp11 = icmp eq i32 0, %call10
36 br i1 %cmp11, label %return, label %do.cond
38 do.cond: ; preds = %land.lhs.true, %do.body
39 %cmp18 = icmp sle i32 0, %call2
40 br i1 %cmp18, label %do.body, label %return
42 return: ; preds = %do.cond, %land.lhs.true, %entry
43 %retval.0 = phi i32 [ 0, %entry ], [ %call6, %land.lhs.true ], [ 0, %do.cond ]
47 define linkonce_odr i32 @bar() nounwind uwtable ssp align 2 {
49 br i1 undef, label %land.lhs.true, label %cond.end
51 land.lhs.true: ; preds = %entry
52 %cmp4 = call zeroext i1 @check()
53 br i1 %cmp4, label %cond.true, label %cond.end
55 cond.true: ; preds = %land.lhs.true
56 %tmp7 = call i32 @getval()
59 cond.end: ; preds = %cond.true, %land.lhs.true, %entry
60 %cond = phi i32 [ %tmp7, %cond.true ], [ 0, %land.lhs.true ], [ 0, %entry ]