1; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s
2
3declare i32 @ret32(i32 returned)
4declare i64 @ret64(i64 returned)
5
6define i64 @test1(i64 %val) {
7; CHECK-LABEL: test1:
8; CHECK-NOT: jmp
9; CHECK: callq
10  %in = trunc i64 %val to i32
11  tail call i32 @ret32(i32 returned %in)
12  ret i64 %val
13}
14
15define i32 @test2(i64 %val) {
16; CHECK-LABEL: test2:
17; CHECK: jmp
18; CHECK-NOT: callq
19  %in = trunc i64 %val to i32
20  tail call i64 @ret64(i64 returned %val)
21  ret i32 %in
22}
23
24define i32 @test3(i64 %in) {
25; CHECK-LABEL: test3:
26; CHECK: jmp
27; CHECK-NOT: callq
28  %small = trunc i64 %in to i32
29  tail call i32 @ret32(i32 returned %small)
30  ret i32 %small
31}
32
33declare {i32, i8} @take_i32_i8({i32, i8} returned)
34define { i8, i8 } @test_nocommon_value({i32, i32} %in) {
35; CHECK-LABEL: test_nocommon_value
36; CHECK: jmp
37
38  %first = extractvalue {i32, i32} %in, 0
39  %first.trunc = trunc i32 %first to i8
40
41  %second = extractvalue {i32, i32} %in, 1
42  %second.trunc = trunc i32 %second to i8
43
44  %tmp = insertvalue {i32, i8} undef, i32 %first, 0
45  %callval = insertvalue {i32, i8} %tmp, i8 %second.trunc, 1
46  tail call {i32, i8} @take_i32_i8({i32, i8} returned %callval)
47
48  %restmp = insertvalue {i8, i8} undef, i8 %first.trunc, 0
49  %res = insertvalue {i8, i8} %restmp, i8 %second.trunc, 1
50  ret {i8, i8} %res
51}
52
53declare {i32, {i32, i32}} @give_i32_i32_i32()
54define {{i32, i32}, i32} @test_structs_different_shape() {
55; CHECK-LABEL: test_structs_different_shape
56; CHECK: jmp
57  %val = tail call {i32, {i32, i32}} @give_i32_i32_i32()
58
59  %first = extractvalue {i32, {i32, i32}} %val, 0
60  %second = extractvalue {i32, {i32, i32}} %val, 1, 0
61  %third = extractvalue {i32, {i32, i32}} %val, 1, 1
62
63  %restmp = insertvalue {{i32, i32}, i32} undef, i32 %first, 0, 0
64  %reseventmper = insertvalue {{i32, i32}, i32} %restmp, i32 %second, 0, 1
65  %res = insertvalue {{i32, i32}, i32} %reseventmper, i32 %third, 1
66
67  ret {{i32, i32}, i32} %res
68}
69
70define i64 @test_undef_asymmetry() {
71; CHECK: test_undef_asymmetry
72; CHECK-NOT: jmp
73  tail call i64 @ret64(i64 returned undef)
74  ret i64 2
75}
76
77define {{}, {{}, i32, {}}, [1 x i32]} @evil_empty_aggregates() {
78; CHECK-LABEL: evil_empty_aggregates
79; CHECK: jmp
80  %agg = tail call {i32, {i32, i32}} @give_i32_i32_i32()
81
82  %first = extractvalue {i32, {i32, i32}} %agg, 0
83  %second = extractvalue {i32, {i32, i32}} %agg, 1, 0
84
85  %restmp = insertvalue {{}, {{}, i32, {}}, [1 x i32]} undef, i32 %first, 1, 1
86  %res = insertvalue {{}, {{}, i32, {}}, [1 x i32]} %restmp, i32 %second, 2, 0
87  ret {{}, {{}, i32, {}}, [1 x i32]} %res
88}
89
90define i32 @structure_is_unimportant() {
91; CHECK-LABEL: structure_is_unimportant
92; CHECK: jmp
93  %val = tail call {i32, {i32, i32}} @give_i32_i32_i32()
94
95  %res = extractvalue {i32, {i32, i32}} %val, 0
96  ret i32 %res
97}
98