1; RUN: llc < %s -mtriple=i386-apple-darwin8 -mattr=+sse2  | FileCheck %s --check-prefix=X32
2; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+sse2 | FileCheck %s --check-prefix=X64
3; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=-sse3 | FileCheck %s --check-prefix=X64_BAD
4
5; Sibcall optimization of expanded libcalls.
6; rdar://8707777
7
8define double @foo(double %a) nounwind readonly ssp {
9entry:
10; X32-LABEL: foo:
11; X32: jmp L_sin$stub
12
13; X64-LABEL: foo:
14; X64: jmp _sin
15  %0 = tail call double @sin(double %a) nounwind readonly
16  ret double %0
17}
18
19define float @bar(float %a) nounwind readonly ssp {
20; X32-LABEL: bar:
21; X32: jmp L_sinf$stub
22
23; X64-LABEL: bar:
24; X64: jmp _sinf
25entry:
26  %0 = tail call float @sinf(float %a) nounwind readonly
27  ret float %0
28}
29
30; X32-LABEL: L_sin$stub:
31; X32-NEXT:   .indirect_symbol        _sin
32; X32-LABEL: L_sinf$stub:
33; X32-NEXT:   .indirect_symbol        _sinf
34
35declare float @sinf(float) nounwind readonly
36
37declare double @sin(double) nounwind readonly
38
39; rdar://10930395
40%0 = type opaque
41
42@"\01L_OBJC_SELECTOR_REFERENCES_2" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
43
44define hidden { double, double } @foo2(%0* %self, i8* nocapture %_cmd) uwtable optsize ssp {
45; X64_BAD: foo
46; X64_BAD: call
47; X64_BAD: call
48; X64_BAD: call
49  %1 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2", align 8, !invariant.load !0
50  %2 = bitcast %0* %self to i8*
51  %3 = tail call { double, double } bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to { double, double } (i8*, i8*)*)(i8* %2, i8* %1) optsize
52  %4 = extractvalue { double, double } %3, 0
53  %5 = extractvalue { double, double } %3, 1
54  %6 = tail call double @floor(double %4) optsize
55  %7 = tail call double @floor(double %5) optsize
56  %insert.i.i = insertvalue { double, double } undef, double %6, 0
57  %insert5.i.i = insertvalue { double, double } %insert.i.i, double %7, 1
58  ret { double, double } %insert5.i.i
59}
60
61declare i8* @objc_msgSend(i8*, i8*, ...)
62
63declare double @floor(double) optsize
64
65!0 = !{}
66