bccd0dfdb3282beafe1cdfa763a0bbbae214bf3e
[oota-llvm.git] / test / Transforms / DeadArgElim / multdeadretval.ll
1 ; This test sees if return values (and arguments) are properly removed when they
2 ; are unused. All unused values are typed i16, so we can easily check. We also
3 ; run instcombine to fold insert/extractvalue chains and we run dce to clean up
4 ; any remaining dead stuff.
5 ; RUN: llvm-as < %s | opt -deadargelim -instcombine -dce | llvm-dis | not grep i16
6
7 define internal {i16, i32} @test(i16 %DEADARG) {
8         %A = insertvalue {i16,i32} undef, i16 1, 0
9         %B = insertvalue {i16,i32} %A, i32 1001, 1
10         ret {i16,i32} %B
11 }
12
13 define internal {i32, i16} @test2() {
14         %DEAD = call i16 @test4()
15         %A = insertvalue {i32,i16} undef, i32 1, 0
16         %B = insertvalue {i32,i16} %A, i16 %DEAD, 1
17         ret {i32,i16} %B
18 }
19
20 define internal i32 @test3(i16 %A) {
21         %ret = call {i16, i32} @test( i16 %A )                ; <i32> [#uses=0]
22         %DEAD = extractvalue {i16, i32} %ret, 0
23         %LIVE = extractvalue {i16, i32} %ret, 1
24         ret i32 %LIVE
25 }
26
27 define internal i16 @test4() {
28         ret i16 0
29 }
30
31 define i32 @main() {
32         %ret = call {i32, i16} @test2()                ; <i32> [#uses=1]
33         %LIVE = extractvalue {i32, i16} %ret, 0
34         %DEAD = extractvalue {i32, i16} %ret, 1
35         %Y = add i32 %LIVE, -123           ; <i32> [#uses=1]
36         %LIVE2 = call i32 @test3(i16 %DEAD)                ; <i32> [#uses=1]
37         %Z = add i32 %LIVE2, %Y           ; <i32> [#uses=1]
38         ret i32 %Z
39 }