From 4f0e429acca3b224b7b58fb89899c2de08a2e4c6 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 6 Sep 2019 16:10:18 +0000 Subject: [PATCH] [SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233) https://bugs.llvm.org/show_bug.cgi?id=43233 llvm-svn: 371221 --- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 4 ++-- llvm/test/Transforms/InstCombine/pow-4.ll | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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 +} + -- 2.7.4