From cebbfacc9e7a6569831cc7e4c0cb63aaeba9ed6a Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 16 Nov 2017 17:06:36 +0000 Subject: [PATCH] [InstCombine] add tests for 'afn' FMF; NFC llvm-svn: 318423 --- llvm/test/Transforms/InstCombine/pow-sqrt.ll | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/pow-sqrt.ll b/llvm/test/Transforms/InstCombine/pow-sqrt.ll index e1ad82746a80..c9e10f08baf6 100644 --- a/llvm/test/Transforms/InstCombine/pow-sqrt.ll +++ b/llvm/test/Transforms/InstCombine/pow-sqrt.ll @@ -19,6 +19,27 @@ define double @pow_neghalf(double %x) { ret double %pow } +define double @pow_half_approx(double %x) { +; CHECK-LABEL: @pow_half_approx( +; CHECK-NEXT: [[SQRT:%.*]] = call double @sqrt(double %x) #1 +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.fabs.f64(double [[SQRT]]) +; CHECK-NEXT: [[TMP2:%.*]] = fcmp oeq double %x, 0xFFF0000000000000 +; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], double 0x7FF0000000000000, double [[TMP1]] +; CHECK-NEXT: ret double [[TMP3]] +; + %pow = call afn double @llvm.pow.f64(double %x, double 5.000000e-01) + ret double %pow +} + +define double @pow_neghalf_approx(double %x) { +; CHECK-LABEL: @pow_neghalf_approx( +; CHECK-NEXT: [[POW:%.*]] = call afn double @llvm.pow.f64(double %x, double -5.000000e-01) +; CHECK-NEXT: ret double [[POW]] +; + %pow = call afn double @llvm.pow.f64(double %x, double -5.000000e-01) + ret double %pow +} + declare double @llvm.pow.f64(double, double) #0 attributes #0 = { nounwind readnone speculatable }