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