blob: 3b87ed3ca6e3249b48eb87c87ba4723c16607f46 [file] [log] [blame]
Evan Cheng73c291782011-01-29 04:53:35 +00001; Duplicate the return into if.end to enable TCE.
Dmitri Gribenko86fb5582013-01-01 14:04:36 +00002; RUN: opt -tailcallelim -stats -disable-output < %s 2>&1 | FileCheck %s
3
4; CHECK: Number of return duplicated
Evan Cheng73c291782011-01-29 04:53:35 +00005
6define i32 @fib(i32 %n) nounwind ssp {
7entry:
8 %cmp = icmp slt i32 %n, 2
9 br i1 %cmp, label %if.then, label %if.end
10
11if.then: ; preds = %entry
12 br label %return
13
14if.end: ; preds = %entry
15 %sub = add nsw i32 %n, -2
16 %call = call i32 @fib(i32 %sub)
17 %sub3 = add nsw i32 %n, -1
18 %call4 = call i32 @fib(i32 %sub3)
19 %add = add nsw i32 %call, %call4
20 br label %return
21
22return: ; preds = %if.end, %if.then
23 %retval.0 = phi i32 [ 1, %if.then ], [ %add, %if.end ]
24 ret i32 %retval.0
25}