aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/X86
diff options
context:
space:
mode:
authorStephen Lin <stephenwlin@gmail.com>2013-04-20 04:27:51 +0000
committerStephen Lin <stephenwlin@gmail.com>2013-04-20 04:27:51 +0000
commit5c34e08b9fff9d4df2421e4f41ff15b85f638dd1 (patch)
treef3b90c7a8ae3510ba68e88d9d0f294876f76830f /test/CodeGen/X86
parentd0ec6ddc1454a00dd9cf9db813433d2953f4c952 (diff)
downloadexternal_llvm-5c34e08b9fff9d4df2421e4f41ff15b85f638dd1.zip
external_llvm-5c34e08b9fff9d4df2421e4f41ff15b85f638dd1.tar.gz
external_llvm-5c34e08b9fff9d4df2421e4f41ff15b85f638dd1.tar.bz2
Allow tail call opportunity detection through nested and/or multiple iterations of extractelement/insertelement indirection
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179924 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86')
-rw-r--r--test/CodeGen/X86/tailcall-64.ll88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/CodeGen/X86/tailcall-64.ll b/test/CodeGen/X86/tailcall-64.ll
index ecc253b..eb2fef0 100644
--- a/test/CodeGen/X86/tailcall-64.ll
+++ b/test/CodeGen/X86/tailcall-64.ll
@@ -50,7 +50,16 @@ define {i64, i64} @test_pair_trivial() {
; CHECK: test_pair_trivial:
; CHECK: jmp _testp ## TAILCALL
+define {i64, i64} @test_pair_notail() {
+ %A = tail call i64 @testi()
+
+ %b = insertvalue {i64, i64} undef, i64 %A, 0
+ %c = insertvalue {i64, i64} %b, i64 %A, 1
+ ret { i64, i64} %c
+}
+; CHECK: test_pair_notail:
+; CHECK-NOT: jmp _testi
define {i64, i64} @test_pair_trivial_extract() {
%A = tail call { i64, i64} @testp()
@@ -66,6 +75,20 @@ define {i64, i64} @test_pair_trivial_extract() {
; CHECK: test_pair_trivial_extract:
; CHECK: jmp _testp ## TAILCALL
+define {i64, i64} @test_pair_notail_extract() {
+ %A = tail call { i64, i64} @testp()
+ %x = extractvalue { i64, i64} %A, 0
+ %y = extractvalue { i64, i64} %A, 1
+
+ %b = insertvalue {i64, i64} undef, i64 %y, 0
+ %c = insertvalue {i64, i64} %b, i64 %x, 1
+
+ ret { i64, i64} %c
+}
+
+; CHECK: test_pair_notail_extract:
+; CHECK-NOT: jmp _testp
+
define {i8*, i64} @test_pair_conv_extract() {
%A = tail call { i64, i64} @testp()
%x = extractvalue { i64, i64} %A, 0
@@ -82,7 +105,72 @@ define {i8*, i64} @test_pair_conv_extract() {
; CHECK: test_pair_conv_extract:
; CHECK: jmp _testp ## TAILCALL
+define {i64, i64} @test_pair_multiple_extract() {
+ %A = tail call { i64, i64} @testp()
+ %x = extractvalue { i64, i64} %A, 0
+ %y = extractvalue { i64, i64} %A, 1
+
+ %b = insertvalue {i64, i64} undef, i64 %x, 0
+ %c = insertvalue {i64, i64} %b, i64 %y, 1
+
+ %x1 = extractvalue { i64, i64} %b, 0
+ %y1 = extractvalue { i64, i64} %c, 1
+
+ %d = insertvalue {i64, i64} undef, i64 %x1, 0
+ %e = insertvalue {i64, i64} %b, i64 %y1, 1
+
+ ret { i64, i64} %e
+}
+
+; CHECK: test_pair_multiple_extract:
+; CHECK: jmp _testp ## TAILCALL
+
+define {i64, i64} @test_pair_undef_extract() {
+ %A = tail call { i64, i64} @testp()
+ %x = extractvalue { i64, i64} %A, 0
+
+ %b = insertvalue {i64, i64} undef, i64 %x, 0
+
+ ret { i64, i64} %b
+}
+
+; CHECK: test_pair_undef_extract:
+; CHECK: jmp _testp ## TAILCALL
+
+declare { i64, { i32, i32 } } @testn()
+
+define {i64, {i32, i32}} @test_nest() {
+ %A = tail call { i64, { i32, i32 } } @testn()
+ %x = extractvalue { i64, { i32, i32}} %A, 0
+ %y = extractvalue { i64, { i32, i32}} %A, 1
+ %y1 = extractvalue { i32, i32} %y, 0
+ %y2 = extractvalue { i32, i32} %y, 1
+
+ %b = insertvalue {i64, {i32, i32}} undef, i64 %x, 0
+ %c1 = insertvalue {i32, i32} undef, i32 %y1, 0
+ %c2 = insertvalue {i32, i32} %c1, i32 %y2, 1
+ %c = insertvalue {i64, {i32, i32}} %b, {i32, i32} %c2, 1
+
+ ret { i64, { i32, i32}} %c
+}
+
+; CHECK: test_nest:
+; CHECK: jmp _testn ## TAILCALL
+
+%struct.A = type { i32 }
+%struct.B = type { %struct.A, i32 }
+
+declare %struct.B* @testu()
+
+define %struct.A* @test_upcast() {
+entry:
+ %A = tail call %struct.B* @testu()
+ %x = getelementptr inbounds %struct.B* %A, i32 0, i32 0
+ ret %struct.A* %x
+}
+; CHECK: test_upcast:
+; CHECK: jmp _testu ## TAILCALL
; PR13006
define { i64, i64 } @crash(i8* %this) {