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-Tag: llvmorg-11-init~9830 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f0e429acca3b224b7b58fb89899c2de08a2e4c6;p=platform%2Fupstream%2Fllvm.git [SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233) https://bugs.llvm.org/show_bug.cgi?id=43233 llvm-svn: 371221 --- diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 1f397c0..7a13cff 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/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/llvm/test/Transforms/InstCombine/pow-4.ll b/llvm/test/Transforms/InstCombine/pow-4.ll index e435239..4aac27f 100644 --- a/llvm/test/Transforms/InstCombine/pow-4.ll +++ b/llvm/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 +} +