diff options
author | Bob Wilson <bob.wilson@apple.com> | 2013-11-03 06:48:38 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2013-11-03 06:48:38 +0000 |
commit | 208130f11331eccab26c0a6f3146cd1891e53e33 (patch) | |
tree | 12cab7de22cfa409359560285db92ac981595524 /test/Transforms | |
parent | cb01efb7988d119d6e2aedab1740695aa6a9cc0c (diff) | |
download | external_llvm-208130f11331eccab26c0a6f3146cd1891e53e33.zip external_llvm-208130f11331eccab26c0a6f3146cd1891e53e33.tar.gz external_llvm-208130f11331eccab26c0a6f3146cd1891e53e33.tar.bz2 |
Convert calls to __sinpi and __cospi into __sincospi_stret
This adds an SimplifyLibCalls case which converts the special __sinpi and
__cospi (float & double variants) into a __sincospi_stret where appropriate to
remove duplicated work.
Patch by Tim Northover
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/InstCombine/sincospi.ll | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/sincospi.ll b/test/Transforms/InstCombine/sincospi.ll new file mode 100644 index 0000000..0d1a602 --- /dev/null +++ b/test/Transforms/InstCombine/sincospi.ll @@ -0,0 +1,91 @@ +; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.9 | FileCheck %s --check-prefix=CHECK-FLOAT-IN-VEC +; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios7.0 | FileCheck %s +; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.8 | FileCheck %s --check-prefix=CHECK-NO-SINCOS +; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios6.0 | FileCheck %s --check-prefix=CHECK-NO-SINCOS +; RUN: opt -instcombine -S < %s -mtriple=x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-NO-SINCOS + + +attributes #0 = { readnone nounwind } + +declare float @__sinpif(float %x) #0 +declare float @__cospif(float %x) #0 + +declare double @__sinpi(double %x) #0 +declare double @__cospi(double %x) #0 + +@var32 = global float 0.0 +@var64 = global double 0.0 + +define float @test_instbased_f32() { + %val = load float* @var32 + %sin = call float @__sinpif(float %val) #0 + %cos = call float @__cospif(float %val) #0 + %res = fadd float %sin, %cos + ret float %res +; CHECK-FLOAT-IN-VEC: [[VAL:%[a-z0-9]+]] = load float* @var32 +; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call <2 x float> @__sincospi_stretf(float [[VAL]]) +; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 0 +; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 1 + +; CHECK: [[VAL:%[a-z0-9]+]] = load float* @var32 +; CHECK: [[SINCOS:%[a-z0-9]+]] = call { float, float } @__sincospi_stretf(float [[VAL]]) +; CHECK: extractvalue { float, float } [[SINCOS]], 0 +; CHECK: extractvalue { float, float } [[SINCOS]], 1 + +; CHECK-NO-SINCOS: call float @__sinpif +; CHECK-NO-SINCOS: call float @__cospif +} + +define float @test_constant_f32() { + %sin = call float @__sinpif(float 1.0) #0 + %cos = call float @__cospif(float 1.0) #0 + %res = fadd float %sin, %cos + ret float %res +; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call <2 x float> @__sincospi_stretf(float 1.000000e+00) +; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 0 +; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 1 + +; CHECK: [[SINCOS:%[a-z0-9]+]] = call { float, float } @__sincospi_stretf(float 1.000000e+00) +; CHECK: extractvalue { float, float } [[SINCOS]], 0 +; CHECK: extractvalue { float, float } [[SINCOS]], 1 + +; CHECK-NO-SINCOS: call float @__sinpif +; CHECK-NO-SINCOS: call float @__cospif +} + +define double @test_instbased_f64() { + %val = load double* @var64 + %sin = call double @__sinpi(double %val) #0 + %cos = call double @__cospi(double %val) #0 + %res = fadd double %sin, %cos + ret double %res +; CHECK-FLOAT-IN-VEC: [[VAL:%[a-z0-9]+]] = load double* @var64 +; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double [[VAL]]) +; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 0 +; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 1 + +; CHECK: [[VAL:%[a-z0-9]+]] = load double* @var64 +; CHECK: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double [[VAL]]) +; CHECK: extractvalue { double, double } [[SINCOS]], 0 +; CHECK: extractvalue { double, double } [[SINCOS]], 1 + +; CHECK-NO-SINCOS: call double @__sinpi +; CHECK-NO-SINCOS: call double @__cospi +} + +define double @test_constant_f64() { + %sin = call double @__sinpi(double 1.0) #0 + %cos = call double @__cospi(double 1.0) #0 + %res = fadd double %sin, %cos + ret double %res +; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double 1.000000e+00) +; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 0 +; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 1 + +; CHECK: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double 1.000000e+00) +; CHECK: extractvalue { double, double } [[SINCOS]], 0 +; CHECK: extractvalue { double, double } [[SINCOS]], 1 + +; CHECK-NO-SINCOS: call double @__sinpi +; CHECK-NO-SINCOS: call double @__cospi +} |