[llvm] r371221 - [SimplifyLibCalls] handle pow(x, -0.0) before it can assert (PR43233)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 02:41:59 PDT 2019


Merged together with the test case from r371224 to release_90 in r371381.

On Fri, Sep 6, 2019 at 6:08 PM Sanjay Patel via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: spatel
> Date: Fri Sep  6 09:10:18 2019
> New Revision: 371221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371221&view=rev
> Log:
> [SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233)
>
> https://bugs.llvm.org/show_bug.cgi?id=43233
>
> Modified:
>     llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
>     llvm/trunk/test/Transforms/InstCombine/pow-4.ll
>
> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=371221&r1=371220&r2=371221&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp Fri Sep  6 09:10:18 2019
> @@ -1562,8 +1562,8 @@ Value *LibCallSimplifier::optimizePow(Ca
>    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
>
> Modified: llvm/trunk/test/Transforms/InstCombine/pow-4.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/pow-4.ll?rev=371221&r1=371220&r2=371221&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/pow-4.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/pow-4.ll Fri Sep  6 09:10:18 2019
> @@ -223,3 +223,13 @@ define <4 x float> @test_simplify_3_5(<4
>    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
> +}
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list