1; RUN: llc -mtriple=x86_64-apple-darwin -o - %s | FileCheck %s
2
3; Simple case: completely identical returns, even with extensions, shouldn't be
4; a barrier to tail calls.
5declare zeroext i1 @give_bool()
6define zeroext i1 @test_bool() {
7; CHECK-LABEL: test_bool:
8; CHECK: jmp
9  %call = tail call zeroext i1 @give_bool()
10  ret i1 %call
11}
12
13; Here, there's more zero extension to be done between the call and the return,
14; so a tail call is impossible (well, according to current Clang practice
15; anyway. The AMD64 ABI isn't crystal clear on the matter).
16; FIXME: The high 24 bits returned from test_i32 are undefined; do tail call!
17declare zeroext i32 @give_i32()
18define zeroext i8 @test_i32() {
19; CHECK-LABEL: test_i32:
20; CHECK: callq _give_i32
21; CHECK: ret
22
23  %call = tail call zeroext i32 @give_i32()
24  %val = trunc i32 %call to i8
25  ret i8 %val
26}
27
28; Here, one function is zeroext and the other is signext. To the extent that
29; these both mean something they are incompatible so no tail call is possible.
30; FIXME: The high 16 bits returned are undefined; do tail call!
31declare zeroext i16 @give_unsigned_i16()
32define signext i16 @test_incompatible_i16() {
33; CHECK-LABEL: test_incompatible_i16:
34; CHECK: callq _give_unsigned_i16
35; CHECK: ret
36
37  %call = tail call zeroext i16 @give_unsigned_i16()
38  ret i16 %call
39}
40
41declare inreg i32 @give_i32_inreg()
42define i32 @test_inreg_to_normal() {
43; CHECK-LABEL: test_inreg_to_normal:
44; CHECK: callq _give_i32_inreg
45; CHECK: ret
46  %val = tail call inreg i32 @give_i32_inreg()
47  ret i32 %val
48}
49
50define inreg i32 @test_normal_to_inreg() {
51; CHECK-LABEL: test_normal_to_inreg:
52; CHECK: callq _give_i32
53; CHECK: ret
54  %val = tail call i32 @give_i32()
55  ret i32 %val
56}
57