diff options
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstCombine/pow-1.ll | 235 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/pow-exp.ll | 40 |
2 files changed, 154 insertions, 121 deletions
diff --git a/llvm/test/Transforms/InstCombine/pow-1.ll b/llvm/test/Transforms/InstCombine/pow-1.ll index b3143b04a3d..1e9b0b59f3f 100644 --- a/llvm/test/Transforms/InstCombine/pow-1.ll +++ b/llvm/test/Transforms/InstCombine/pow-1.ll @@ -1,13 +1,14 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; Test that the pow library call simplifier works correctly. ; -; RUN: opt < %s -instcombine -S | FileCheck %s -; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.9 | FileCheck %s --check-prefix=CHECK-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios7.0 | FileCheck %s --check-prefix=CHECK-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.8 | FileCheck %s --check-prefix=CHECK-NO-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios6.0 | FileCheck %s --check-prefix=CHECK-NO-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=x86_64-netbsd | FileCheck %s --check-prefix=CHECK-NO-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=arm-apple-tvos9.0 | FileCheck %s --check-prefix=CHECK-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=arm-apple-watchos2.0 | FileCheck %s --check-prefix=CHECK-EXP10 +; RUN: opt -instcombine -S < %s | FileCheck %s --check-prefixes=ANY +; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.9 | FileCheck %s --check-prefixes=ANY,CHECK-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios7.0 | FileCheck %s --check-prefixes=ANY,CHECK-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.8 | FileCheck %s --check-prefixes=ANY,CHECK-NO-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios6.0 | FileCheck %s --check-prefixes=ANY,CHECK-NO-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=x86_64-netbsd | FileCheck %s --check-prefixes=ANY,CHECK-NO-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=arm-apple-tvos9.0 | FileCheck %s --check-prefixes=ANY,CHECK-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=arm-apple-watchos2.0 | FileCheck %s --check-prefixes=ANY,CHECK-EXP10 ; rdar://7251832 ; NOTE: The readonly attribute on the pow call should be preserved @@ -21,199 +22,220 @@ declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>) nounwind readon ; Check pow(1.0, x) -> 1.0. define float @test_simplify1(float %x) { -; CHECK-LABEL: @test_simplify1( +; ANY-LABEL: @test_simplify1( +; ANY-NEXT: ret float 1.000000e+00 +; %retval = call float @powf(float 1.0, float %x) ret float %retval -; CHECK-NEXT: ret float 1.000000e+00 } define <2 x float> @test_simplify1v(<2 x float> %x) { -; CHECK-LABEL: @test_simplify1v( +; ANY-LABEL: @test_simplify1v( +; ANY-NEXT: ret <2 x float> <float 1.000000e+00, float 1.000000e+00> +; %retval = call <2 x float> @llvm.pow.v2f32(<2 x float> <float 1.0, float 1.0>, <2 x float> %x) ret <2 x float> %retval -; CHECK-NEXT: ret <2 x float> <float 1.000000e+00, float 1.000000e+00> } define double @test_simplify2(double %x) { -; CHECK-LABEL: @test_simplify2( +; ANY-LABEL: @test_simplify2( +; ANY-NEXT: ret double 1.000000e+00 +; %retval = call double @pow(double 1.0, double %x) ret double %retval -; CHECK-NEXT: ret double 1.000000e+00 } define <2 x double> @test_simplify2v(<2 x double> %x) { -; CHECK-LABEL: @test_simplify2v( +; ANY-LABEL: @test_simplify2v( +; ANY-NEXT: ret <2 x double> <double 1.000000e+00, double 1.000000e+00> +; %retval = call <2 x double> @llvm.pow.v2f64(<2 x double> <double 1.0, double 1.0>, <2 x double> %x) ret <2 x double> %retval -; CHECK-NEXT: ret <2 x double> <double 1.000000e+00, double 1.000000e+00> } ; Check pow(2.0, x) -> exp2(x). define float @test_simplify3(float %x) { -; CHECK-LABEL: @test_simplify3( +; ANY-LABEL: @test_simplify3( +; ANY-NEXT: [[EXP2:%.*]] = call float @llvm.exp2.f32(float [[X:%.*]]) +; ANY-NEXT: ret float [[EXP2]] +; %retval = call float @powf(float 2.0, float %x) -; CHECK-NEXT: [[EXP2F:%[a-z0-9]+]] = call float @llvm.exp2.f32(float %x) ret float %retval -; CHECK-NEXT: ret float [[EXP2F]] } define <2 x float> @test_simplify3v(<2 x float> %x) { -; CHECK-LABEL: @test_simplify3v( +; ANY-LABEL: @test_simplify3v( +; ANY-NEXT: [[EXP2:%.*]] = call <2 x float> @llvm.exp2.v2f32(<2 x float> [[X:%.*]]) +; ANY-NEXT: ret <2 x float> [[EXP2]] +; %retval = call <2 x float> @llvm.pow.v2f32(<2 x float> <float 2.0, float 2.0>, <2 x float> %x) -; CHECK-NEXT: [[EXP2F:%[a-z0-9]+]] = call <2 x float> @llvm.exp2.v2f32(<2 x float> %x) ret <2 x float> %retval -; CHECK-NEXT: ret <2 x float> [[EXP2F]] } define double @test_simplify4(double %x) { -; CHECK-LABEL: @test_simplify4( +; ANY-LABEL: @test_simplify4( +; ANY-NEXT: [[EXP2:%.*]] = call double @llvm.exp2.f64(double [[X:%.*]]) +; ANY-NEXT: ret double [[EXP2]] +; %retval = call double @pow(double 2.0, double %x) -; CHECK-NEXT: [[EXP2:%[a-z0-9]+]] = call double @llvm.exp2.f64(double %x) ret double %retval -; CHECK-NEXT: ret double [[EXP2]] } define <2 x double> @test_simplify4v(<2 x double> %x) { -; CHECK-LABEL: @test_simplify4v( +; ANY-LABEL: @test_simplify4v( +; ANY-NEXT: [[EXP2:%.*]] = call <2 x double> @llvm.exp2.v2f64(<2 x double> [[X:%.*]]) +; ANY-NEXT: ret <2 x double> [[EXP2]] +; %retval = call <2 x double> @llvm.pow.v2f64(<2 x double> <double 2.0, double 2.0>, <2 x double> %x) -; CHECK-NEXT: [[EXP2:%[a-z0-9]+]] = call <2 x double> @llvm.exp2.v2f64(<2 x double> %x) ret <2 x double> %retval -; CHECK-NEXT: ret <2 x double> [[EXP2]] } ; Check pow(x, 0.0) -> 1.0. define float @test_simplify5(float %x) { -; CHECK-LABEL: @test_simplify5( +; ANY-LABEL: @test_simplify5( +; ANY-NEXT: ret float 1.000000e+00 +; %retval = call float @powf(float %x, float 0.0) ret float %retval -; CHECK-NEXT: ret float 1.000000e+00 } define <2 x float> @test_simplify5v(<2 x float> %x) { -; CHECK-LABEL: @test_simplify5v( +; ANY-LABEL: @test_simplify5v( +; ANY-NEXT: ret <2 x float> <float 1.000000e+00, float 1.000000e+00> +; %retval = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 0.0, float 0.0>) ret <2 x float> %retval -; CHECK-NEXT: ret <2 x float> <float 1.000000e+00, float 1.000000e+00> } define double @test_simplify6(double %x) { -; CHECK-LABEL: @test_simplify6( +; ANY-LABEL: @test_simplify6( +; ANY-NEXT: ret double 1.000000e+00 +; %retval = call double @pow(double %x, double 0.0) ret double %retval -; CHECK-NEXT: ret double 1.000000e+00 } define <2 x double> @test_simplify6v(<2 x double> %x) { -; CHECK-LABEL: @test_simplify6v( +; ANY-LABEL: @test_simplify6v( +; ANY-NEXT: ret <2 x double> <double 1.000000e+00, double 1.000000e+00> +; %retval = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 0.0, double 0.0>) ret <2 x double> %retval -; CHECK-NEXT: ret <2 x double> <double 1.000000e+00, double 1.000000e+00> } ; Check pow(x, 0.5) -> fabs(sqrt(x)), where x != -infinity. define float @test_simplify7(float %x) { -; CHECK-LABEL: @test_simplify7( +; ANY-LABEL: @test_simplify7( +; ANY-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) #0 +; ANY-NEXT: [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]]) +; ANY-NEXT: [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000 +; ANY-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]] +; ANY-NEXT: ret float [[TMP1]] +; %retval = call float @powf(float %x, float 0.5) -; CHECK-NEXT: [[SQRTF:%[a-z0-9]+]] = call float @sqrtf(float %x) [[$NUW_RO:#[0-9]+]] -; CHECK-NEXT: [[FABSF:%[a-z0-9]+]] = call float @llvm.fabs.f32(float [[SQRTF]]) -; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq float %x, 0xFFF0000000000000 -; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], float 0x7FF0000000000000, float [[FABSF]] ret float %retval -; CHECK-NEXT: ret float [[SELECT]] } define double @test_simplify8(double %x) { -; CHECK-LABEL: @test_simplify8( +; ANY-LABEL: @test_simplify8( +; ANY-NEXT: [[SQRT:%.*]] = call double @sqrt(double [[X:%.*]]) #0 +; ANY-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[SQRT]]) +; ANY-NEXT: [[ISINF:%.*]] = fcmp oeq double [[X]], 0xFFF0000000000000 +; ANY-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], double 0x7FF0000000000000, double [[ABS]] +; ANY-NEXT: ret double [[TMP1]] +; %retval = call double @pow(double %x, double 0.5) -; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) [[$NUW_RO]] -; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @llvm.fabs.f64(double [[SQRT]]) -; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq double %x, 0xFFF0000000000000 -; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], double 0x7FF0000000000000, double [[FABS]] ret double %retval -; CHECK-NEXT: ret double [[SELECT]] } ; Check pow(-infinity, 0.5) -> +infinity. define float @test_simplify9(float %x) { -; CHECK-LABEL: @test_simplify9( +; ANY-LABEL: @test_simplify9( +; ANY-NEXT: ret float 0x7FF0000000000000 +; %retval = call float @powf(float 0xFFF0000000000000, float 0.5) ret float %retval -; CHECK-NEXT: ret float 0x7FF0000000000000 } define double @test_simplify10(double %x) { -; CHECK-LABEL: @test_simplify10( +; ANY-LABEL: @test_simplify10( +; ANY-NEXT: ret double 0x7FF0000000000000 +; %retval = call double @pow(double 0xFFF0000000000000, double 0.5) ret double %retval -; CHECK-NEXT: ret double 0x7FF0000000000000 } ; Check pow(x, 1.0) -> x. define float @test_simplify11(float %x) { -; CHECK-LABEL: @test_simplify11( +; ANY-LABEL: @test_simplify11( +; ANY-NEXT: ret float [[X:%.*]] +; %retval = call float @powf(float %x, float 1.0) ret float %retval -; CHECK-NEXT: ret float %x } define <2 x float> @test_simplify11v(<2 x float> %x) { -; CHECK-LABEL: @test_simplify11v( +; ANY-LABEL: @test_simplify11v( +; ANY-NEXT: ret <2 x float> [[X:%.*]] +; %retval = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 1.0, float 1.0>) ret <2 x float> %retval -; CHECK-NEXT: ret <2 x float> %x } define double @test_simplify12(double %x) { -; CHECK-LABEL: @test_simplify12( +; ANY-LABEL: @test_simplify12( +; ANY-NEXT: ret double [[X:%.*]] +; %retval = call double @pow(double %x, double 1.0) ret double %retval -; CHECK-NEXT: ret double %x } define <2 x double> @test_simplify12v(<2 x double> %x) { -; CHECK-LABEL: @test_simplify12v( +; ANY-LABEL: @test_simplify12v( +; ANY-NEXT: ret <2 x double> [[X:%.*]] +; %retval = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 1.0, double 1.0>) ret <2 x double> %retval -; CHECK-NEXT: ret <2 x double> %x } ; Check pow(x, 2.0) -> x*x. define float @pow2_strict(float %x) { -; CHECK-LABEL: @pow2_strict( -; CHECK-NEXT: [[POW2:%.*]] = fmul float %x, %x -; CHECK-NEXT: ret float [[POW2]] +; ANY-LABEL: @pow2_strict( +; ANY-NEXT: [[SQUARE:%.*]] = fmul float [[X:%.*]], [[X]] +; ANY-NEXT: ret float [[SQUARE]] ; %r = call float @powf(float %x, float 2.0) ret float %r } define <2 x float> @pow2_strictv(<2 x float> %x) { -; CHECK-LABEL: @pow2_strictv( -; CHECK-NEXT: [[POW2:%.*]] = fmul <2 x float> %x, %x -; CHECK-NEXT: ret <2 x float> [[POW2]] +; ANY-LABEL: @pow2_strictv( +; ANY-NEXT: [[SQUARE:%.*]] = fmul <2 x float> [[X:%.*]], [[X]] +; ANY-NEXT: ret <2 x float> [[SQUARE]] ; %r = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 2.0, float 2.0>) ret <2 x float> %r } define double @pow2_double_strict(double %x) { -; CHECK-LABEL: @pow2_double_strict( -; CHECK-NEXT: [[POW2:%.*]] = fmul double %x, %x -; CHECK-NEXT: ret double [[POW2]] +; ANY-LABEL: @pow2_double_strict( +; ANY-NEXT: [[SQUARE:%.*]] = fmul double [[X:%.*]], [[X]] +; ANY-NEXT: ret double [[SQUARE]] ; %r = call double @pow(double %x, double 2.0) ret double %r } + define <2 x double> @pow2_double_strictv(<2 x double> %x) { -; CHECK-LABEL: @pow2_double_strictv( -; CHECK-NEXT: [[POW2:%.*]] = fmul <2 x double> %x, %x -; CHECK-NEXT: ret <2 x double> [[POW2]] +; ANY-LABEL: @pow2_double_strictv( +; ANY-NEXT: [[SQUARE:%.*]] = fmul <2 x double> [[X:%.*]], [[X]] +; ANY-NEXT: ret <2 x double> [[SQUARE]] ; %r = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 2.0, double 2.0>) ret <2 x double> %r @@ -222,9 +244,9 @@ define <2 x double> @pow2_double_strictv(<2 x double> %x) { ; Don't drop the FMF - PR35601 ( https://bugs.llvm.org/show_bug.cgi?id=35601 ) define float @pow2_fast(float %x) { -; CHECK-LABEL: @pow2_fast( -; CHECK-NEXT: [[POW2:%.*]] = fmul fast float %x, %x -; CHECK-NEXT: ret float [[POW2]] +; ANY-LABEL: @pow2_fast( +; ANY-NEXT: [[SQUARE:%.*]] = fmul fast float [[X:%.*]], [[X]] +; ANY-NEXT: ret float [[SQUARE]] ; %r = call fast float @powf(float %x, float 2.0) ret float %r @@ -233,36 +255,36 @@ define float @pow2_fast(float %x) { ; Check pow(x, -1.0) -> 1.0/x. define float @pow_neg1_strict(float %x) { -; CHECK-LABEL: @pow_neg1_strict( -; CHECK-NEXT: [[POWRECIP:%.*]] = fdiv float 1.000000e+00, %x -; CHECK-NEXT: ret float [[POWRECIP]] +; ANY-LABEL: @pow_neg1_strict( +; ANY-NEXT: [[RECIPROCAL:%.*]] = fdiv float 1.000000e+00, [[X:%.*]] +; ANY-NEXT: ret float [[RECIPROCAL]] ; %r = call float @powf(float %x, float -1.0) ret float %r } define <2 x float> @pow_neg1_strictv(<2 x float> %x) { -; CHECK-LABEL: @pow_neg1_strictv( -; CHECK-NEXT: [[POWRECIP:%.*]] = fdiv <2 x float> <float 1.000000e+00, float 1.000000e+00>, %x -; CHECK-NEXT: ret <2 x float> [[POWRECIP]] +; ANY-LABEL: @pow_neg1_strictv( +; ANY-NEXT: [[RECIPROCAL:%.*]] = fdiv <2 x float> <float 1.000000e+00, float 1.000000e+00>, [[X:%.*]] +; ANY-NEXT: ret <2 x float> [[RECIPROCAL]] ; %r = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float -1.0, float -1.0>) ret <2 x float> %r } define double @pow_neg1_double_fast(double %x) { -; CHECK-LABEL: @pow_neg1_double_fast( -; CHECK-NEXT: [[POWRECIP:%.*]] = fdiv fast double 1.000000e+00, %x -; CHECK-NEXT: ret double [[POWRECIP]] +; ANY-LABEL: @pow_neg1_double_fast( +; ANY-NEXT: [[RECIPROCAL:%.*]] = fdiv fast double 1.000000e+00, [[X:%.*]] +; ANY-NEXT: ret double [[RECIPROCAL]] ; %r = call fast double @pow(double %x, double -1.0) ret double %r } define <2 x double> @pow_neg1_double_fastv(<2 x double> %x) { -; CHECK-LABEL: @pow_neg1_double_fastv( -; CHECK-NEXT: [[POWRECIP:%.*]] = fdiv fast <2 x double> <double 1.000000e+00, double 1.000000e+00>, %x -; CHECK-NEXT: ret <2 x double> [[POWRECIP]] +; ANY-LABEL: @pow_neg1_double_fastv( +; ANY-NEXT: [[RECIPROCAL:%.*]] = fdiv fast <2 x double> <double 1.000000e+00, double 1.000000e+00>, [[X:%.*]] +; ANY-NEXT: ret <2 x double> [[RECIPROCAL]] ; %r = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double -1.0, double -1.0>) ret <2 x double> %r @@ -270,35 +292,44 @@ define <2 x double> @pow_neg1_double_fastv(<2 x double> %x) { declare double @llvm.pow.f64(double %Val, double %Power) define double @test_simplify17(double %x) { -; CHECK-LABEL: @test_simplify17( +; ANY-LABEL: @test_simplify17( +; ANY-NEXT: [[SQRT:%.*]] = call double @sqrt(double [[X:%.*]]) #2 +; ANY-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[SQRT]]) +; ANY-NEXT: [[ISINF:%.*]] = fcmp oeq double [[X]], 0xFFF0000000000000 +; ANY-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], double 0x7FF0000000000000, double [[ABS]] +; ANY-NEXT: ret double [[TMP1]] +; %retval = call double @llvm.pow.f64(double %x, double 0.5) -; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) -; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @llvm.fabs.f64(double [[SQRT]]) -; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq double %x, 0xFFF0000000000000 -; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], double 0x7FF0000000000000, double [[FABS]] ret double %retval -; CHECK-NEXT: ret double [[SELECT]] } ; Check pow(10.0, x) -> __exp10(x) on OS X 10.9+ and iOS 7.0+. define float @test_simplify18(float %x) { -; CHECK-LABEL: @test_simplify18( +; CHECK-EXP10-LABEL: @test_simplify18( +; CHECK-EXP10-NEXT: [[__EXP10F:%.*]] = call float @__exp10f(float [[X:%.*]]) [[NUW_RO:#[0-9]+]] +; CHECK-EXP10-NEXT: ret float [[__EXP10F]] +; +; CHECK-NO-EXP10-LABEL: @test_simplify18( +; CHECK-NO-EXP10-NEXT: [[RETVAL:%.*]] = call float @powf(float 1.000000e+01, float [[X:%.*]]) +; CHECK-NO-EXP10-NEXT: ret float [[RETVAL]] +; %retval = call float @powf(float 10.0, float %x) -; CHECK-EXP10: [[EXP10F:%[_a-z0-9]+]] = call float @__exp10f(float %x) [[$NUW_RO:#[0-9]+]] ret float %retval -; CHECK-EXP10: ret float [[EXP10F]] -; CHECK-NO-EXP10: call float @powf } define double @test_simplify19(double %x) { -; CHECK-LABEL: @test_simplify19( +; CHECK-EXP10-LABEL: @test_simplify19( +; CHECK-EXP10-NEXT: [[__EXP10:%.*]] = call double @__exp10(double [[X:%.*]]) [[NUW_RO]] +; CHECK-EXP10-NEXT: ret double [[__EXP10]] +; +; CHECK-NO-EXP10-LABEL: @test_simplify19( +; CHECK-NO-EXP10-NEXT: [[RETVAL:%.*]] = call double @pow(double 1.000000e+01, double [[X:%.*]]) +; CHECK-NO-EXP10-NEXT: ret double [[RETVAL]] +; %retval = call double @pow(double 10.0, double %x) -; CHECK-EXP10: [[EXP10:%[_a-z0-9]+]] = call double @__exp10(double %x) [[$NUW_RO]] ret double %retval -; CHECK-EXP10: ret double [[EXP10]] -; CHECK-NO-EXP10: call double @pow } -; CHECK: attributes [[$NUW_RO]] = { nounwind readonly } +; CHECK-EXP10: attributes [[NUW_RO]] = { nounwind readonly } diff --git a/llvm/test/Transforms/InstCombine/pow-exp.ll b/llvm/test/Transforms/InstCombine/pow-exp.ll index 594594abd7d..8714a762785 100644 --- a/llvm/test/Transforms/InstCombine/pow-exp.ll +++ b/llvm/test/Transforms/InstCombine/pow-exp.ll @@ -1,48 +1,50 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instcombine -S | FileCheck %s define double @pow_exp(double %x, double %y) { +; CHECK-LABEL: @pow_exp( +; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[EXP:%.*]] = call fast double @exp(double [[MUL]]) +; CHECK-NEXT: ret double [[EXP]] +; %call = call fast double @exp(double %x) nounwind readnone %pow = call fast double @llvm.pow.f64(double %call, double %y) ret double %pow } -; CHECK-LABEL: define double @pow_exp( -; CHECK-NEXT: %mul = fmul fast double %x, %y -; CHECK-NEXT: %exp = call fast double @exp(double %mul) -; CHECK-NEXT: ret double %exp - define double @pow_exp2(double %x, double %y) { +; CHECK-LABEL: @pow_exp2( +; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[EXP2:%.*]] = call fast double @exp2(double [[MUL]]) +; CHECK-NEXT: ret double [[EXP2]] +; %call = call fast double @exp2(double %x) nounwind readnone %pow = call fast double @llvm.pow.f64(double %call, double %y) ret double %pow } -; CHECK-LABEL: define double @pow_exp2( -; CHECK-NEXT: %mul = fmul fast double %x, %y -; CHECK-NEXT: %exp2 = call fast double @exp2(double %mul) -; CHECK-NEXT: ret double %exp2 - define double @pow_exp_not_fast(double %x, double %y) { +; CHECK-LABEL: @pow_exp_not_fast( +; CHECK-NEXT: [[CALL:%.*]] = call double @exp(double [[X:%.*]]) +; CHECK-NEXT: [[POW:%.*]] = call fast double @llvm.pow.f64(double [[CALL]], double [[Y:%.*]]) +; CHECK-NEXT: ret double [[POW]] +; %call = call double @exp(double %x) %pow = call fast double @llvm.pow.f64(double %call, double %y) ret double %pow } -; CHECK-LABEL: define double @pow_exp_not_fast( -; CHECK-NEXT: %call = call double @exp(double %x) -; CHECK-NEXT: %pow = call fast double @llvm.pow.f64(double %call, double %y) -; CHECK-NEXT: ret double %pow - define double @function_pointer(double ()* %fptr, double %p1) { +; CHECK-LABEL: @function_pointer( +; CHECK-NEXT: [[CALL1:%.*]] = call fast double [[FPTR:%.*]]() +; CHECK-NEXT: [[POW:%.*]] = call fast double @llvm.pow.f64(double [[CALL1]], double [[P1:%.*]]) +; CHECK-NEXT: ret double [[POW]] +; %call1 = call fast double %fptr() %pow = call fast double @llvm.pow.f64(double %call1, double %p1) ret double %pow } -; CHECK-LABEL: @function_pointer -; CHECK-NEXT: %call1 = call fast double %fptr() -; CHECK-NEXT: %pow = call fast double @llvm.pow.f64(double %call1, double %p1) - declare double @exp(double) declare double @exp2(double) declare double @llvm.pow.f64(double, double) |