llvm.org GIT mirror llvm / f88776c
merge two tests and convert to filecheck. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112613 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
2 changed file(s) with 28 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
None ; RUN: opt < %s -tailcallelim -S | not grep call
0 ; RUN: opt < %s -tailcallelim -S | FileCheck %s
11
2 define i32 @factorial(i32 %x) {
2 define i32 @test1_factorial(i32 %x) {
33 entry:
44 %tmp.1 = icmp sgt i32 %x, 0 ; [#uses=1]
55 br i1 %tmp.1, label %then, label %else
66 then: ; preds = %entry
77 %tmp.6 = add i32 %x, -1 ; [#uses=1]
8 %tmp.4 = call i32 @factorial( i32 %tmp.6 ) ; [#uses=1]
8 %tmp.4 = call i32 @test1_factorial( i32 %tmp.6 ) ; [#uses=1]
99 %tmp.7 = mul i32 %tmp.4, %x ; [#uses=1]
1010 ret i32 %tmp.7
1111 else: ; preds = %entry
1212 ret i32 1
1313 }
1414
15 ; CHECK: define i32 @test1_factorial
16 ; CHECK: phi i32
17 ; CHECK-NOT: call i32
18 ; CHECK: else:
19
20 ; This is a more aggressive form of accumulator recursion insertion, which
21 ; requires noticing that X doesn't change as we perform the tailcall.
22
23 define i32 @test2_mul(i32 %x, i32 %y) {
24 entry:
25 %tmp.1 = icmp eq i32 %y, 0 ; [#uses=1]
26 br i1 %tmp.1, label %return, label %endif
27 endif: ; preds = %entry
28 %tmp.8 = add i32 %y, -1 ; [#uses=1]
29 %tmp.5 = call i32 @test2_mul( i32 %x, i32 %tmp.8 ) ; [#uses=1]
30 %tmp.9 = add i32 %tmp.5, %x ; [#uses=1]
31 ret i32 %tmp.9
32 return: ; preds = %entry
33 ret i32 %x
34 }
35
36 ; CHECK: define i32 @test2_mul
37 ; CHECK: phi i32
38 ; CHECK-NOT: call i32
39 ; CHECK: return:
+0
-20
test/Transforms/TailCallElim/accum_recursion_constant_arg.ll less more
None ; This is a more aggressive form of accumulator recursion insertion, which
1 ; requires noticing that X doesn't change as we perform the tailcall. Thanks
2 ; go out to the anonymous users of the demo script for "suggesting"
3 ; optimizations that should be done. :)
4
5 ; RUN: opt < %s -tailcallelim -S | not grep call
6
7 define i32 @mul(i32 %x, i32 %y) {
8 entry:
9 %tmp.1 = icmp eq i32 %y, 0 ; [#uses=1]
10 br i1 %tmp.1, label %return, label %endif
11 endif: ; preds = %entry
12 %tmp.8 = add i32 %y, -1 ; [#uses=1]
13 %tmp.5 = call i32 @mul( i32 %x, i32 %tmp.8 ) ; [#uses=1]
14 %tmp.9 = add i32 %tmp.5, %x ; [#uses=1]
15 ret i32 %tmp.9
16 return: ; preds = %entry
17 ret i32 %x
18 }
19