1; RUN: llc < %s -mtriple=armv7-apple-ios6 -mcpu=cortex-a8 | FileCheck %s --check-prefix=NOOPT 2; RUN: llc < %s -mtriple=armv7-apple-ios7 -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS 3; RUN: llc < %s -mtriple=armv7-linux-gnu -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU 4; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a8 \ 5; RUN: --enable-unsafe-fp-math | FileCheck %s --check-prefix=SINCOS-GNU 6 7; Combine sin / cos into a single call unless they may write errno (as 8; captured by readnone attrbiute, controlled by clang -fmath-errno 9; setting). 10; rdar://12856873 11 12define float @test1(float %x) nounwind { 13entry: 14; SINCOS-LABEL: test1: 15; SINCOS: bl ___sincosf_stret 16 17; SINCOS-GNU-LABEL: test1: 18; SINCOS-GNU: bl sincosf 19 20; NOOPT-LABEL: test1: 21; NOOPT: bl _sinf 22; NOOPT: bl _cosf 23 24 %call = tail call float @sinf(float %x) readnone 25 %call1 = tail call float @cosf(float %x) readnone 26 %add = fadd float %call, %call1 27 ret float %add 28} 29 30define float @test1_errno(float %x) nounwind { 31entry: 32; SINCOS-LABEL: test1_errno: 33; SINCOS: bl _sinf 34; SINCOS: bl _cosf 35 36; SINCOS-GNU-LABEL: test1_errno: 37; SINCOS-GNU: bl sinf 38; SINCOS-GNU: bl cosf 39 40; NOOPT-LABEL: test1_errno: 41; NOOPT: bl _sinf 42; NOOPT: bl _cosf 43 44 %call = tail call float @sinf(float %x) 45 %call1 = tail call float @cosf(float %x) 46 %add = fadd float %call, %call1 47 ret float %add 48} 49 50define double @test2(double %x) nounwind { 51entry: 52; SINCOS-LABEL: test2: 53; SINCOS: bl ___sincos_stret 54 55; SINCOS-GNU-LABEL: test2: 56; SINCOS-GNU: bl sincos 57 58; NOOPT-LABEL: test2: 59; NOOPT: bl _sin 60; NOOPT: bl _cos 61 62 %call = tail call double @sin(double %x) readnone 63 %call1 = tail call double @cos(double %x) readnone 64 %add = fadd double %call, %call1 65 ret double %add 66} 67 68define double @test2_errno(double %x) nounwind { 69entry: 70; SINCOS-LABEL: test2_errno: 71; SINCOS: bl _sin 72; SINCOS: bl _cos 73 74; SINCOS-GNU-LABEL: test2_errno: 75; SINCOS-GNU: bl sin 76; SINCOS-GNU: bl cos 77 78; NOOPT-LABEL: test2_errno: 79; NOOPT: bl _sin 80; NOOPT: bl _cos 81 82 %call = tail call double @sin(double %x) 83 %call1 = tail call double @cos(double %x) 84 %add = fadd double %call, %call1 85 ret double %add 86} 87 88declare float @sinf(float) 89declare double @sin(double) 90declare float @cosf(float) 91declare double @cos(double) 92