1 ; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.9 | FileCheck %s --check-prefix=CHECK-FLOAT-IN-VEC
2 ; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios7.0 | FileCheck %s
3 ; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.8 | FileCheck %s --check-prefix=CHECK-NO-SINCOS
4 ; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios6.0 | FileCheck %s --check-prefix=CHECK-NO-SINCOS
5 ; RUN: opt -instcombine -S < %s -mtriple=x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-NO-SINCOS
8 attributes #0 = { readnone nounwind }
10 declare float @__sinpif(float %x) #0
11 declare float @__cospif(float %x) #0
13 declare double @__sinpi(double %x) #0
14 declare double @__cospi(double %x) #0
16 @var32 = global float 0.0
17 @var64 = global double 0.0
19 define float @test_instbased_f32() {
20 %val = load float* @var32
21 %sin = call float @__sinpif(float %val) #0
22 %cos = call float @__cospif(float %val) #0
23 %res = fadd float %sin, %cos
25 ; CHECK-FLOAT-IN-VEC: [[VAL:%[a-z0-9]+]] = load float* @var32
26 ; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call <2 x float> @__sincospi_stretf(float [[VAL]])
27 ; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 0
28 ; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 1
30 ; CHECK: [[VAL:%[a-z0-9]+]] = load float* @var32
31 ; CHECK: [[SINCOS:%[a-z0-9]+]] = call { float, float } @__sincospi_stretf(float [[VAL]])
32 ; CHECK: extractvalue { float, float } [[SINCOS]], 0
33 ; CHECK: extractvalue { float, float } [[SINCOS]], 1
35 ; CHECK-NO-SINCOS: call float @__sinpif
36 ; CHECK-NO-SINCOS: call float @__cospif
39 define float @test_constant_f32() {
40 %sin = call float @__sinpif(float 1.0) #0
41 %cos = call float @__cospif(float 1.0) #0
42 %res = fadd float %sin, %cos
44 ; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call <2 x float> @__sincospi_stretf(float 1.000000e+00)
45 ; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 0
46 ; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 1
48 ; CHECK: [[SINCOS:%[a-z0-9]+]] = call { float, float } @__sincospi_stretf(float 1.000000e+00)
49 ; CHECK: extractvalue { float, float } [[SINCOS]], 0
50 ; CHECK: extractvalue { float, float } [[SINCOS]], 1
52 ; CHECK-NO-SINCOS: call float @__sinpif
53 ; CHECK-NO-SINCOS: call float @__cospif
56 define double @test_instbased_f64() {
57 %val = load double* @var64
58 %sin = call double @__sinpi(double %val) #0
59 %cos = call double @__cospi(double %val) #0
60 %res = fadd double %sin, %cos
62 ; CHECK-FLOAT-IN-VEC: [[VAL:%[a-z0-9]+]] = load double* @var64
63 ; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double [[VAL]])
64 ; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 0
65 ; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 1
67 ; CHECK: [[VAL:%[a-z0-9]+]] = load double* @var64
68 ; CHECK: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double [[VAL]])
69 ; CHECK: extractvalue { double, double } [[SINCOS]], 0
70 ; CHECK: extractvalue { double, double } [[SINCOS]], 1
72 ; CHECK-NO-SINCOS: call double @__sinpi
73 ; CHECK-NO-SINCOS: call double @__cospi
76 define double @test_constant_f64() {
77 %sin = call double @__sinpi(double 1.0) #0
78 %cos = call double @__cospi(double 1.0) #0
79 %res = fadd double %sin, %cos
81 ; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double 1.000000e+00)
82 ; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 0
83 ; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 1
85 ; CHECK: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double 1.000000e+00)
86 ; CHECK: extractvalue { double, double } [[SINCOS]], 0
87 ; CHECK: extractvalue { double, double } [[SINCOS]], 1
89 ; CHECK-NO-SINCOS: call double @__sinpi
90 ; CHECK-NO-SINCOS: call double @__cospi