diff options
author | Meador Inge <meadori@codesourcery.com> | 2012-11-13 04:16:17 +0000 |
---|---|---|
committer | Meador Inge <meadori@codesourcery.com> | 2012-11-13 04:16:17 +0000 |
commit | 2920a71663b96f2c33b1fee09ca5ca9f5dc1cf12 (patch) | |
tree | de057ca88e82ce75a40dc65a04b4d4db0db0a2ec /test/Transforms/SimplifyLibCalls | |
parent | 4712b804dfe02bc7bbf948f9a5e352b3f14cc89a (diff) |
instcombine: Migrate math library call simplifications
This patch migrates the math library call simplifications from the
simplify-libcalls pass into the instcombine library call simplifier.
I have typically migrated just one simplifier at a time, but the math
simplifiers are interdependent because:
1. CosOpt, PowOpt, and Exp2Opt all depend on UnaryDoubleFPOpt.
2. CosOpt, PowOpt, Exp2Opt, and UnaryDoubleFPOpt all depend on
the option -enable-double-float-shrink.
These two factors made migrating each of these simplifiers individually
more of a pain than it would be worth. So, I migrated them all together.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyLibCalls')
-rw-r--r-- | test/Transforms/SimplifyLibCalls/cos.ll | 14 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/double-float-shrink.ll | 333 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/exp2.ll | 38 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/floor.ll | 85 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/pow-to-sqrt.ll | 33 | ||||
-rw-r--r-- | test/Transforms/SimplifyLibCalls/pow2.ll | 37 |
6 files changed, 0 insertions, 540 deletions
diff --git a/test/Transforms/SimplifyLibCalls/cos.ll b/test/Transforms/SimplifyLibCalls/cos.ll deleted file mode 100644 index 6a8ce8c388..0000000000 --- a/test/Transforms/SimplifyLibCalls/cos.ll +++ /dev/null @@ -1,14 +0,0 @@ -; RUN: opt < %s -simplify-libcalls -S | FileCheck %s - -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -define double @foo(double %d) nounwind readnone { -; CHECK: @foo - %1 = fsub double -0.000000e+00, %d - %2 = call double @cos(double %1) nounwind readnone -; CHECK: call double @cos(double %d) - ret double %2 -} - -declare double @cos(double) nounwind readnone diff --git a/test/Transforms/SimplifyLibCalls/double-float-shrink.ll b/test/Transforms/SimplifyLibCalls/double-float-shrink.ll deleted file mode 100644 index b4ab8b4ceb..0000000000 --- a/test/Transforms/SimplifyLibCalls/double-float-shrink.ll +++ /dev/null @@ -1,333 +0,0 @@ -; RUN: opt < %s -simplify-libcalls -enable-double-float-shrink -S | FileCheck %s - -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -define float @acos_test(float %f) nounwind readnone { -; CHECK: acos_test - %conv = fpext float %f to double - %call = call double @acos(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @acosf(float %f) -} - -define double @acos_test2(float %f) nounwind readnone { -; CHECK: acos_test2 - %conv = fpext float %f to double - %call = call double @acos(double %conv) - ret double %call -; CHECK: call double @acos(double %conv) -} - -define float @acosh_test(float %f) nounwind readnone { -; CHECK: acosh_test - %conv = fpext float %f to double - %call = call double @acosh(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @acoshf(float %f) -} - -define double @acosh_test2(float %f) nounwind readnone { -; CHECK: acosh_test2 - %conv = fpext float %f to double - %call = call double @acosh(double %conv) - ret double %call -; CHECK: call double @acosh(double %conv) -} - -define float @asin_test(float %f) nounwind readnone { -; CHECK: asin_test - %conv = fpext float %f to double - %call = call double @asin(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @asinf(float %f) -} - -define double @asin_test2(float %f) nounwind readnone { -; CHECK: asin_test2 - %conv = fpext float %f to double - %call = call double @asin(double %conv) - ret double %call -; CHECK: call double @asin(double %conv) -} - -define float @asinh_test(float %f) nounwind readnone { -; CHECK: asinh_test - %conv = fpext float %f to double - %call = call double @asinh(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @asinhf(float %f) -} - -define double @asinh_test2(float %f) nounwind readnone { -; CHECK: asinh_test2 - %conv = fpext float %f to double - %call = call double @asinh(double %conv) - ret double %call -; CHECK: call double @asinh(double %conv) -} - -define float @atan_test(float %f) nounwind readnone { -; CHECK: atan_test - %conv = fpext float %f to double - %call = call double @atan(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @atanf(float %f) -} - -define double @atan_test2(float %f) nounwind readnone { -; CHECK: atan_test2 - %conv = fpext float %f to double - %call = call double @atan(double %conv) - ret double %call -; CHECK: call double @atan(double %conv) -} -define float @atanh_test(float %f) nounwind readnone { -; CHECK: atanh_test - %conv = fpext float %f to double - %call = call double @atanh(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @atanhf(float %f) -} - -define double @atanh_test2(float %f) nounwind readnone { -; CHECK: atanh_test2 - %conv = fpext float %f to double - %call = call double @atanh(double %conv) - ret double %call -; CHECK: call double @atanh(double %conv) -} -define float @cbrt_test(float %f) nounwind readnone { -; CHECK: cbrt_test - %conv = fpext float %f to double - %call = call double @cbrt(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @cbrtf(float %f) -} - -define double @cbrt_test2(float %f) nounwind readnone { -; CHECK: cbrt_test2 - %conv = fpext float %f to double - %call = call double @cbrt(double %conv) - ret double %call -; CHECK: call double @cbrt(double %conv) -} -define float @exp_test(float %f) nounwind readnone { -; CHECK: exp_test - %conv = fpext float %f to double - %call = call double @exp(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @expf(float %f) -} - -define double @exp_test2(float %f) nounwind readnone { -; CHECK: exp_test2 - %conv = fpext float %f to double - %call = call double @exp(double %conv) - ret double %call -; CHECK: call double @exp(double %conv) -} -define float @expm1_test(float %f) nounwind readnone { -; CHECK: expm1_test - %conv = fpext float %f to double - %call = call double @expm1(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @expm1f(float %f) -} - -define double @expm1_test2(float %f) nounwind readnone { -; CHECK: expm1_test2 - %conv = fpext float %f to double - %call = call double @expm1(double %conv) - ret double %call -; CHECK: call double @expm1(double %conv) -} -define float @exp10_test(float %f) nounwind readnone { -; CHECK: exp10_test - %conv = fpext float %f to double - %call = call double @exp10(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @exp10f(float %f) -} - -define double @exp10_test2(float %f) nounwind readnone { -; CHECK: exp10_test2 - %conv = fpext float %f to double - %call = call double @exp10(double %conv) - ret double %call -; CHECK: call double @exp10(double %conv) -} -define float @log_test(float %f) nounwind readnone { -; CHECK: log_test - %conv = fpext float %f to double - %call = call double @log(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @logf(float %f) -} - -define double @log_test2(float %f) nounwind readnone { -; CHECK: log_test2 - %conv = fpext float %f to double - %call = call double @log(double %conv) - ret double %call -; CHECK: call double @log(double %conv) -} -define float @log10_test(float %f) nounwind readnone { -; CHECK: log10_test - %conv = fpext float %f to double - %call = call double @log10(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @log10f(float %f) -} - -define double @log10_test2(float %f) nounwind readnone { -; CHECK: log10_test2 - %conv = fpext float %f to double - %call = call double @log10(double %conv) - ret double %call -; CHECK: call double @log10(double %conv) -} -define float @log1p_test(float %f) nounwind readnone { -; CHECK: log1p_test - %conv = fpext float %f to double - %call = call double @log1p(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @log1pf(float %f) -} - -define double @log1p_test2(float %f) nounwind readnone { -; CHECK: log1p_test2 - %conv = fpext float %f to double - %call = call double @log1p(double %conv) - ret double %call -; CHECK: call double @log1p(double %conv) -} -define float @log2_test(float %f) nounwind readnone { -; CHECK: log2_test - %conv = fpext float %f to double - %call = call double @log2(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @log2f(float %f) -} - -define double @log2_test2(float %f) nounwind readnone { -; CHECK: log2_test2 - %conv = fpext float %f to double - %call = call double @log2(double %conv) - ret double %call -; CHECK: call double @log2(double %conv) -} -define float @logb_test(float %f) nounwind readnone { -; CHECK: logb_test - %conv = fpext float %f to double - %call = call double @logb(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @logbf(float %f) -} - -define double @logb_test2(float %f) nounwind readnone { -; CHECK: logb_test2 - %conv = fpext float %f to double - %call = call double @logb(double %conv) - ret double %call -; CHECK: call double @logb(double %conv) -} -define float @sin_test(float %f) nounwind readnone { -; CHECK: sin_test - %conv = fpext float %f to double - %call = call double @sin(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @sinf(float %f) -} - -define double @sin_test2(float %f) nounwind readnone { -; CHECK: sin_test2 - %conv = fpext float %f to double - %call = call double @sin(double %conv) - ret double %call -; CHECK: call double @sin(double %conv) -} -define float @sqrt_test(float %f) nounwind readnone { -; CHECK: sqrt_test - %conv = fpext float %f to double - %call = call double @sqrt(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @sqrtf(float %f) -} - -define double @sqrt_test2(float %f) nounwind readnone { -; CHECK: sqrt_test2 - %conv = fpext float %f to double - %call = call double @sqrt(double %conv) - ret double %call -; CHECK: call double @sqrt(double %conv) -} -define float @tan_test(float %f) nounwind readnone { -; CHECK: tan_test - %conv = fpext float %f to double - %call = call double @tan(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @tanf(float %f) -} - -define double @tan_test2(float %f) nounwind readnone { -; CHECK: tan_test2 - %conv = fpext float %f to double - %call = call double @tan(double %conv) - ret double %call -; CHECK: call double @tan(double %conv) -} -define float @tanh_test(float %f) nounwind readnone { -; CHECK: tanh_test - %conv = fpext float %f to double - %call = call double @tanh(double %conv) - %conv1 = fptrunc double %call to float - ret float %conv1 -; CHECK: call float @tanhf(float %f) -} - -define double @tanh_test2(float %f) nounwind readnone { -; CHECK: tanh_test2 - %conv = fpext float %f to double - %call = call double @tanh(double %conv) - ret double %call -; CHECK: call double @tanh(double %conv) -} - -declare double @tanh(double) nounwind readnone -declare double @tan(double) nounwind readnone -declare double @sqrt(double) nounwind readnone -declare double @sin(double) nounwind readnone -declare double @log2(double) nounwind readnone -declare double @log1p(double) nounwind readnone -declare double @log10(double) nounwind readnone -declare double @log(double) nounwind readnone -declare double @logb(double) nounwind readnone -declare double @exp10(double) nounwind readnone -declare double @expm1(double) nounwind readnone -declare double @exp(double) nounwind readnone -declare double @cbrt(double) nounwind readnone -declare double @atanh(double) nounwind readnone -declare double @atan(double) nounwind readnone -declare double @acos(double) nounwind readnone -declare double @acosh(double) nounwind readnone -declare double @asin(double) nounwind readnone -declare double @asinh(double) nounwind readnone diff --git a/test/Transforms/SimplifyLibCalls/exp2.ll b/test/Transforms/SimplifyLibCalls/exp2.ll deleted file mode 100644 index a5927757cf..0000000000 --- a/test/Transforms/SimplifyLibCalls/exp2.ll +++ /dev/null @@ -1,38 +0,0 @@ -; RUN: opt < %s -simplify-libcalls -S | grep "call.*ldexp" | count 4 -; rdar://5852514 - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin8" - -define double @t1(i32 %x) nounwind { -entry: - %tmp12 = sitofp i32 %x to double ; <double> [#uses=1] - %exp2 = tail call double @exp2( double %tmp12 ) ; <double> [#uses=1] - ret double %exp2 -} - -define float @t4(i8 zeroext %x) nounwind { -entry: - %tmp12 = uitofp i8 %x to float ; <float> [#uses=1] - %tmp3 = tail call float @exp2f( float %tmp12 ) nounwind readonly ; <float> [#uses=1] - ret float %tmp3 -} - -declare float @exp2f(float) nounwind readonly - -define double @t3(i16 zeroext %x) nounwind { -entry: - %tmp12 = uitofp i16 %x to double ; <double> [#uses=1] - %exp2 = tail call double @exp2( double %tmp12 ) ; <double> [#uses=1] - ret double %exp2 -} - -define double @t2(i16 signext %x) nounwind { -entry: - %tmp12 = sitofp i16 %x to double ; <double> [#uses=1] - %exp2 = tail call double @exp2( double %tmp12 ) ; <double> [#uses=1] - ret double %exp2 -} - -declare double @exp2(double) - diff --git a/test/Transforms/SimplifyLibCalls/floor.ll b/test/Transforms/SimplifyLibCalls/floor.ll deleted file mode 100644 index 93c62c2002..0000000000 --- a/test/Transforms/SimplifyLibCalls/floor.ll +++ /dev/null @@ -1,85 +0,0 @@ -; RUN: opt < %s -simplify-libcalls -S -mtriple "i386-pc-linux" | FileCheck -check-prefix=DO-SIMPLIFY %s -; RUN: opt < %s -simplify-libcalls -S -mtriple "i386-pc-win32" | FileCheck -check-prefix=DONT-SIMPLIFY %s -; RUN: opt < %s -simplify-libcalls -S -mtriple "x86_64-pc-win32" | FileCheck -check-prefix=C89-SIMPLIFY %s -; RUN: opt < %s -simplify-libcalls -S -mtriple "i386-pc-mingw32" | FileCheck -check-prefix=DO-SIMPLIFY %s -; RUN: opt < %s -simplify-libcalls -S -mtriple "x86_64-pc-mingw32" | FileCheck -check-prefix=DO-SIMPLIFY %s -; RUN: opt < %s -simplify-libcalls -S -mtriple "sparc-sun-solaris" | FileCheck -check-prefix=DO-SIMPLIFY %s - -; DO-SIMPLIFY: call float @floorf( -; DO-SIMPLIFY: call float @ceilf( -; DO-SIMPLIFY: call float @roundf( -; DO-SIMPLIFY: call float @nearbyintf( -; DO-SIMPLIFY: call float @truncf( -; DO-SIMPLIFY: call float @fabsf( - -; C89-SIMPLIFY: call float @floorf( -; C89-SIMPLIFY: call float @ceilf( -; C89-SIMPLIFY: call double @round( -; C89-SIMPLIFY: call double @nearbyint( - -; DONT-SIMPLIFY: call double @floor( -; DONT-SIMPLIFY: call double @ceil( -; DONT-SIMPLIFY: call double @round( -; DONT-SIMPLIFY: call double @nearbyint( -; DONT-SIMPLIFY: call double @trunc( -; DONT-SIMPLIFY: call double @fabs( - -declare double @floor(double) - -declare double @ceil(double) - -declare double @round(double) - -declare double @nearbyint(double) - -declare double @trunc(double) - -declare double @fabs(double) - -define float @test_floor(float %C) { - %D = fpext float %C to double ; <double> [#uses=1] - ; --> floorf - %E = call double @floor( double %D ) ; <double> [#uses=1] - %F = fptrunc double %E to float ; <float> [#uses=1] - ret float %F -} - -define float @test_ceil(float %C) { - %D = fpext float %C to double ; <double> [#uses=1] - ; --> ceilf - %E = call double @ceil( double %D ) ; <double> [#uses=1] - %F = fptrunc double %E to float ; <float> [#uses=1] - ret float %F -} - -define float @test_round(float %C) { - %D = fpext float %C to double ; <double> [#uses=1] - ; --> roundf - %E = call double @round( double %D ) ; <double> [#uses=1] - %F = fptrunc double %E to float ; <float> [#uses=1] - ret float %F -} - -define float @test_nearbyint(float %C) { - %D = fpext float %C to double ; <double> [#uses=1] - ; --> nearbyintf - %E = call double @nearbyint( double %D ) ; <double> [#uses=1] - %F = fptrunc double %E to float ; <float> [#uses=1] - ret float %F -} - -define float @test_trunc(float %C) { - %D = fpext float %C to double - ; --> truncf - %E = call double @trunc(double %D) - %F = fptrunc double %E to float - ret float %F -} - -define float @test_fabs(float %C) { - %D = fpext float %C to double - ; --> fabsf - %E = call double @fabs(double %D) - %F = fptrunc double %E to float - ret float %F -} diff --git a/test/Transforms/SimplifyLibCalls/pow-to-sqrt.ll b/test/Transforms/SimplifyLibCalls/pow-to-sqrt.ll deleted file mode 100644 index 0480fdda89..0000000000 --- a/test/Transforms/SimplifyLibCalls/pow-to-sqrt.ll +++ /dev/null @@ -1,33 +0,0 @@ -; RUN: opt < %s -simplify-libcalls -S | FileCheck %s -; rdar://7251832 - -; SimplifyLibcalls should optimize pow(x, 0.5) to sqrt plus code to handle -; special cases. The readonly attribute on the call should be preserved. - -; CHECK: define float @foo(float %x) nounwind { -; CHECK: %sqrtf = call float @sqrtf(float %x) nounwind readonly -; CHECK: %fabsf = call float @fabsf(float %sqrtf) nounwind readonly -; CHECK: %1 = fcmp oeq float %x, 0xFFF0000000000000 -; CHECK: %retval = select i1 %1, float 0x7FF0000000000000, float %fabsf -; CHECK: ret float %retval - -define float @foo(float %x) nounwind { - %retval = call float @powf(float %x, float 0.5) - ret float %retval -} - -; CHECK: define double @doo(double %x) nounwind { -; CHECK: %sqrt = call double @sqrt(double %x) nounwind readonly -; CHECK: %fabs = call double @fabs(double %sqrt) nounwind readonly -; CHECK: %1 = fcmp oeq double %x, 0xFFF0000000000000 -; CHECK: %retval = select i1 %1, double 0x7FF0000000000000, double %fabs -; CHECK: ret double %retval -; CHECK: } - -define double @doo(double %x) nounwind { - %retval = call double @pow(double %x, double 0.5) - ret double %retval -} - -declare float @powf(float, float) nounwind readonly -declare double @pow(double, double) nounwind readonly diff --git a/test/Transforms/SimplifyLibCalls/pow2.ll b/test/Transforms/SimplifyLibCalls/pow2.ll deleted file mode 100644 index f0964e7d6d..0000000000 --- a/test/Transforms/SimplifyLibCalls/pow2.ll +++ /dev/null @@ -1,37 +0,0 @@ -; Testcase for calls to the standard C "pow" function -; -; RUN: opt < %s -simplify-libcalls -S | not grep "call .pow" - - -declare double @pow(double, double) -declare float @powf(float, float) - -define double @test1(double %X) { - %Y = call double @pow( double %X, double 0.000000e+00 ) ; <double> [#uses=1] - ret double %Y -} - -define double @test2(double %X) { - %Y = call double @pow( double %X, double -0.000000e+00 ) ; <double> [#uses=1] - ret double %Y -} - -define double @test3(double %X) { - %Y = call double @pow( double 1.000000e+00, double %X ) ; <double> [#uses=1] - ret double %Y -} - -define double @test4(double %X) { - %Y = call double @pow( double %X, double 2.0) - ret double %Y -} - -define float @test4f(float %X) { - %Y = call float @powf( float %X, float 2.0) - ret float %Y -} - -define float @test5f(float %X) { - %Y = call float @powf(float 2.0, float %X) ;; exp2 - ret float %Y -} |