180 lines · plain
1; RUN: llc < %s -mtriple=x86_64-apple-macosx10.9.0 -mcpu=core2 | FileCheck %s --check-prefix=OSX_SINCOS2; RUN: llc < %s -mtriple=x86_64-apple-macosx10.8.0 -mcpu=core2 | FileCheck %s --check-prefix=OSX_NOOPT3; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS4; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH5; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH6; RUN: llc < %s -mtriple=x86_64-fuchsia -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS7; RUN: llc < %s -mtriple=x86_64-fuchsia -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH8; RUN: llc < %s -mtriple=x86_64-scei-ps4 -mcpu=btver2 | FileCheck %s --check-prefix=PS4_SINCOS9; RUN: llc < %s -mtriple=x86_64-sie-ps5 -mcpu=znver2 | FileCheck %s --check-prefix=PS4_SINCOS10 11; Combine sin / cos into a single call unless they may write errno (as12; captured by readnone attrbiute, controlled by clang -fmath-errno13; setting).14; rdar://1308796915; rdar://1359949316 17define float @test1(float %x) nounwind {18entry:19; GNU_SINCOS-LABEL: test1:20; GNU_SINCOS: callq sincosf21; GNU_SINCOS: movss 4(%rsp), %xmm022; GNU_SINCOS: addss (%rsp), %xmm023 24; GNU_SINCOS_FASTMATH-LABEL: test1:25; GNU_SINCOS_FASTMATH: callq sincosf26; GNU_SINCOS_FASTMATH: movss 4(%{{[re]}}sp), %xmm027; GNU_SINCOS_FASTMATH: addss (%{{[re]}}sp), %xmm028 29; OSX_SINCOS-LABEL: test1:30; OSX_SINCOS: callq ___sincosf_stret31; OSX_SINCOS: movshdup {{.*}} xmm1 = xmm0[1,1,3,3]32; OSX_SINCOS: addss %xmm1, %xmm033 34; OSX_NOOPT-LABEL: test1:35; OSX_NOOPT: callq _sinf36; OSX_NOOPT: callq _cosf37 38; PS4_SINCOS-LABEL: test1:39; PS4_SINCOS: callq sincosf40; PS4_SINCOS: vmovss 4(%rsp), %xmm041; PS4_SINCOS: vaddss (%rsp), %xmm0, %xmm042 %call = tail call float @sinf(float %x) readnone43 %call1 = tail call float @cosf(float %x) readnone44 %add = fadd float %call, %call145 ret float %add46}47 48define float @test1_errno(float %x) nounwind {49entry:50; GNU_SINCOS-LABEL: test1_errno:51; GNU_SINCOS: callq sinf52; GNU_SINCOS: callq cosf53 54; GNU_SINCOS_FASTMATH-LABEL: test1_errno:55; GNU_SINCOS_FASTMATH: callq sinf56; GNU_SINCOS_FASTMATH: callq cosf57 58; OSX_SINCOS-LABEL: test1_errno:59; OSX_SINCOS: callq _sinf60; OSX_SINCOS: callq _cosf61 62; OSX_NOOPT-LABEL: test1_errno:63; OSX_NOOPT: callq _sinf64; OSX_NOOPT: callq _cosf65 66; PS4_SINCOS-LABEL: test1_errno:67; PS4_SINCOS: callq sinf68; PS4_SINCOS: callq cosf69 %call = tail call float @sinf(float %x)70 %call1 = tail call float @cosf(float %x)71 %add = fadd float %call, %call172 ret float %add73}74 75define double @test2(double %x) nounwind {76entry:77; GNU_SINCOS-LABEL: test2:78; GNU_SINCOS: callq sincos79; GNU_SINCOS: movsd 16(%rsp), %xmm080; GNU_SINCOS: addsd 8(%rsp), %xmm081 82; GNU_SINCOS_FASTMATH-LABEL: test2:83; GNU_SINCOS_FASTMATH: callq sincos84; GNU_SINCOS_FASTMATH: movsd 16(%{{[re]}}sp), %xmm085; GNU_SINCOS_FASTMATH: addsd 8(%{{[re]}}sp), %xmm086 87; OSX_SINCOS-LABEL: test2:88; OSX_SINCOS: callq ___sincos_stret89; OSX_SINCOS: addsd %xmm1, %xmm090 91; OSX_NOOPT-LABEL: test2:92; OSX_NOOPT: callq _sin93; OSX_NOOPT: callq _cos94 95; PS4_SINCOS-LABEL: test2:96; PS4_SINCOS: callq sincos97; PS4_SINCOS: vmovsd 16(%rsp), %xmm098; PS4_SINCOS: vaddsd 8(%rsp), %xmm0, %xmm099 %call = tail call double @sin(double %x) readnone100 %call1 = tail call double @cos(double %x) readnone101 %add = fadd double %call, %call1102 ret double %add103}104 105define double @test2_errno(double %x) nounwind {106entry:107; GNU_SINCOS-LABEL: test2_errno:108; GNU_SINCOS: callq sin109; GNU_SINCOS: callq cos110 111; GNU_SINCOS_FASTMATH-LABEL: test2_errno:112; GNU_SINCOS_FASTMATH: callq sin113; GNU_SINCOS_FASTMATH: callq cos114 115; OSX_SINCOS-LABEL: test2_errno:116; OSX_SINCOS: callq _sin117; OSX_SINCOS: callq _cos118 119; OSX_NOOPT-LABEL: test2_errno:120; OSX_NOOPT: callq _sin121; OSX_NOOPT: callq _cos122 123; PS4_SINCOS-LABEL: test2_errno:124; PS4_SINCOS: callq sin125; PS4_SINCOS: callq cos126 %call = tail call double @sin(double %x)127 %call1 = tail call double @cos(double %x)128 %add = fadd double %call, %call1129 ret double %add130}131 132define x86_fp80 @test3(x86_fp80 %x) nounwind {133entry:134; GNU_SINCOS-LABEL: test3:135; GNU_SINCOS: callq sincosl136; GNU_SINCOS: fldt 16(%rsp)137; GNU_SINCOS: fldt 32(%rsp)138; GNU_SINCOS: faddp %st, %st(1)139 140; GNU_SINCOS_FASTMATH-LABEL: test3:141; GNU_SINCOS_FASTMATH: callq sincosl142; GNU_SINCOS_FASTMATH: fldt 16(%{{[re]}}sp)143; GNU_SINCOS_FASTMATH: fldt 32(%{{[re]}}sp)144; GNU_SINCOS_FASTMATH: faddp %st, %st(1)145 146; PS4_SINCOS-LABEL: test3:147; PS4_SINCOS: callq sinl148; PS4_SINCOS: callq cosl149 %call = tail call x86_fp80 @sinl(x86_fp80 %x) readnone150 %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) readnone151 %add = fadd x86_fp80 %call, %call1152 ret x86_fp80 %add153}154 155define x86_fp80 @test3_errno(x86_fp80 %x) nounwind {156entry:157; GNU_SINCOS-LABEL: test3_errno:158; GNU_SINCOS: callq sinl159; GNU_SINCOS: callq cosl160 161; GNU_SINCOS_FASTMATH-LABEL: test3_errno:162; GNU_SINCOS_FASTMATH: callq sinl163; GNU_SINCOS_FASTMATH: callq cosl164 165; PS4_SINCOS-LABEL: test3_errno:166; PS4_SINCOS: callq sinl167; PS4_SINCOS: callq cosl168 %call = tail call x86_fp80 @sinl(x86_fp80 %x)169 %call1 = tail call x86_fp80 @cosl(x86_fp80 %x)170 %add = fadd x86_fp80 %call, %call1171 ret x86_fp80 %add172}173 174declare float @sinf(float)175declare double @sin(double)176declare float @cosf(float)177declare double @cos(double)178declare x86_fp80 @sinl(x86_fp80)179declare x86_fp80 @cosl(x86_fp80)180