From: Sanjay Patel Date: Fri, 6 Sep 2019 16:10:18 +0000 (+0000) Subject: [SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0cd0037f5cda148baf2d7da836903bfd302560b7;p=llvm [SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233) https://bugs.llvm.org/show_bug.cgi?id=43233 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371221 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp index 1f397c0dedb..7a13cff1193 100644 --- a/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1562,8 +1562,8 @@ Value *LibCallSimplifier::optimizePow(CallInst *Pow, IRBuilder<> &B) { if (match(Expo, m_SpecificFP(-1.0))) return B.CreateFDiv(ConstantFP::get(Ty, 1.0), Base, "reciprocal"); - // pow(x, 0.0) -> 1.0 - if (match(Expo, m_SpecificFP(0.0))) + // pow(x, +/-0.0) -> 1.0 + if (match(Expo, m_AnyZeroFP())) return ConstantFP::get(Ty, 1.0); // pow(x, 1.0) -> x diff --git a/test/Transforms/InstCombine/pow-4.ll b/test/Transforms/InstCombine/pow-4.ll index e4352392e22..4aac27fe72f 100644 --- a/test/Transforms/InstCombine/pow-4.ll +++ b/test/Transforms/InstCombine/pow-4.ll @@ -223,3 +223,13 @@ define <4 x float> @test_simplify_3_5(<4 x float> %x) { ret <4 x float> %1 } +; Make sure that -0.0 exponent is always simplified. + +define double @PR43233(double %x) { +; CHECK-LABEL: @PR43233( +; CHECK-NEXT: ret double 1.000000e+00 +; + %r = call fast double @llvm.pow.f64(double %x, double -0.0) + ret double %r +} +